parent
eb35470954
commit
ef6149fee4
@ -0,0 +1,2 @@
|
||||
schedule==1.2.1
|
||||
telebot==0.0.5
|
@ -1,25 +1,38 @@
|
||||
import schedule
|
||||
import time
|
||||
from time import sleep
|
||||
import telebot
|
||||
from db import *
|
||||
db = read_db()
|
||||
bot = telebot.TeleBot(db['token'])
|
||||
from db import read_db, write_db
|
||||
token = read_db()["token"]
|
||||
bot = telebot.TeleBot(token)
|
||||
|
||||
|
||||
def send_message():
|
||||
db = read_db()
|
||||
for i in db:
|
||||
if i != "token":
|
||||
database = read_db()
|
||||
for chat_id in database:
|
||||
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')
|
||||
if chat_id != "token":
|
||||
for user_id in database[chat_id]:
|
||||
lunch = database[chat_id][user_id]["lunch"]
|
||||
if lunch > 0:
|
||||
if lunch == 1: obed = "обеда"
|
||||
else: obed = "обедов"
|
||||
text += f'<a href="tg://user?id={user_id}">Пользователь</a> убил {lunch} {obed}😿\n'
|
||||
database[chat_id][user_id]["lunch"] = 0
|
||||
else:
|
||||
text += f'<a href="tg://user?id={user_id}">Пользователь</a> молодец!\n'
|
||||
write_db(database)
|
||||
bot.send_message(int(chat_id), text, parse_mode='HTML')
|
||||
|
||||
schedule.every().day.at("21:00","Europe/Moscow").do(send_message)
|
||||
while True:
|
||||
|
||||
def main():
|
||||
schedule.every().day.at('21:00', 'Europe/Moscow').do(send_message)
|
||||
while True:
|
||||
try:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
||||
except: ...
|
||||
sleep(1)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in new issue