parent
d196d144ea
commit
02b2336b98
@ -1,22 +1,25 @@
|
|||||||
from datetime import datetime
|
import schedule
|
||||||
import time
|
import time
|
||||||
import telebot
|
import telebot
|
||||||
from db import *
|
from db import *
|
||||||
db = read_db()
|
db = read_db()
|
||||||
bot = telebot.TeleBot(db['token'])
|
bot = telebot.TeleBot(db['token'])
|
||||||
|
|
||||||
|
|
||||||
|
def send_message():
|
||||||
|
db = read_db()
|
||||||
|
for i in db:
|
||||||
|
if i != "token":
|
||||||
|
text = 'Статистика обедов за 24 часа:\n'
|
||||||
|
for j in db[i]:
|
||||||
|
text += f'@{db[i][j]["username"]} - {db[i][j]["lunch"]} 😿\n'
|
||||||
|
db[i][j]["lunch"] = 0
|
||||||
|
write_db(db)
|
||||||
|
bot.send_message(int(i), text, parse_mode='HTML')
|
||||||
|
|
||||||
|
schedule.every().day.at("21:00","Europe/Moscow").do(send_message)
|
||||||
while True:
|
while True:
|
||||||
now = datetime.now()
|
try:
|
||||||
current_time = now.strftime("%H:%M")
|
schedule.run_pending()
|
||||||
if current_time == "21:00":
|
time.sleep(1)
|
||||||
db = read_db()
|
except: exit()
|
||||||
for i in db:
|
|
||||||
if i != "token":
|
|
||||||
text = 'Статистика обедов за 24 часа::\n'
|
|
||||||
for j in i:
|
|
||||||
text += f'<a href="tg://user?id={j}">Пользователь</a>: {db[i][j]} обедов.\n'
|
|
||||||
db[i][j] = 0
|
|
||||||
write_db(db)
|
|
||||||
bot.send_message(int(i),
|
|
||||||
text,
|
|
||||||
parse_mode='HTML')
|
|
||||||
time.sleep(61)
|
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
import schedule
|
||||||
|
import time
|
||||||
|
import telebot
|
||||||
|
from db import *
|
||||||
|
db = read_db()
|
||||||
|
bot = telebot.TeleBot(db['token'])
|
||||||
|
|
||||||
|
|
||||||
|
def send_message():
|
||||||
|
db = read_db()
|
||||||
|
for i in db:
|
||||||
|
if i != "token":
|
||||||
|
text = 'Статистика обедов за 24 часа:\n'
|
||||||
|
for j in i:
|
||||||
|
text += f'<a href="tg://user?id={j}">Пользователь</a>: {db[i][j]} обедов.\n'
|
||||||
|
db[i][j] = 0
|
||||||
|
write_db(db)
|
||||||
|
bot.send_message(int(i), text, parse_mode='HTML')
|
||||||
|
|
||||||
|
schedule.every().day.at("21:24","Europe/Moscow").do(send_message)
|
||||||
|
while True:
|
||||||
|
schedule.run_pending()
|
||||||
|
time.sleep(1)
|
Loading…
Reference in new issue