parent
81f29dc9f8
commit
0b2b98209e
@ -0,0 +1,20 @@
|
||||
####### CREATE DB IF NOT EXIST
|
||||
import os, json
|
||||
if not os.path.exists('db.json'):
|
||||
db = {'token': 'None'}
|
||||
js = json.dumps(db, indent=2)
|
||||
with open('db.json', 'w') as outfile:
|
||||
outfile.write(js)
|
||||
print('Input token in "None" (db.json)')
|
||||
exit()
|
||||
|
||||
############WORK WITH DBs##########
|
||||
def read_db():
|
||||
with open('db.json', 'r') as openfile:
|
||||
db = json.load(openfile)
|
||||
return db
|
||||
|
||||
def write_db(db):
|
||||
js = json.dumps(db, indent=2)
|
||||
with open('db.json', 'w') as outfile:
|
||||
outfile.write(js)
|
@ -0,0 +1,22 @@
|
||||
from datetime import datetime
|
||||
import time
|
||||
import telebot
|
||||
from db import *
|
||||
db = read_db()
|
||||
bot = telebot.TeleBot(db['token'])
|
||||
while True:
|
||||
now = datetime.now()
|
||||
current_time = now.strftime("%H:%M")
|
||||
if current_time == "16:10":
|
||||
db = read_db()
|
||||
for i in db:
|
||||
if i != "token" and db[i] != 0:
|
||||
text = ''
|
||||
for j in i:
|
||||
text += f"{db[i][j]}\n"
|
||||
db[i][j] = 0
|
||||
write_db(db)
|
||||
bot.send_message(int(j),
|
||||
text,
|
||||
parse_mode='HTML')
|
||||
time.sleep(61)
|
Loading…
Reference in new issue