I'm finally done with this Telegram bot
This commit is contained in:
parent
5f2594ed4a
commit
ef2d9a520b
|
@ -39,16 +39,13 @@ def subscribe(message):
|
|||
bot.send_message(message.chat.id, "You are subscribed")
|
||||
|
||||
def recheck():
|
||||
time.sleep(1)
|
||||
time.sleep(60)
|
||||
send_notification()
|
||||
|
||||
def send_notification():
|
||||
# Inserisci il giorno di oggi
|
||||
today = datetime.datetime.today().strftime('%A')
|
||||
# Print hours
|
||||
tomorrow = (datetime.datetime.today() + datetime.timedelta(days=1)).strftime('%A')
|
||||
now = datetime.datetime.now()
|
||||
print(now.strftime("%H:%M"))
|
||||
finish = False
|
||||
if today == "Saturday" or today == "Sunday":
|
||||
print("Today is weekend")
|
||||
else:
|
||||
|
@ -61,27 +58,40 @@ def send_notification():
|
|||
if now.strftime("%H:%M") == "07:50":
|
||||
for i in find_document:
|
||||
for b in array_username:
|
||||
bot.send_message(b, i['School Subject'][today][0]['Subject'])
|
||||
elif now.strftime("%H:%M") == "08:53":
|
||||
bot.send_message(b, str(i['School Subject']['Monday'][0]['Room']) + ", " + i['School Subject']['Monday'][0]['Teacher'] + ", " + i['School Subject']['Monday'][0]['Subject'] + "\n" + "Successiva: " + str(i['School Subject']['Monday'][1]['Room']) + ", " + i['School Subject']['Monday'][1]['Teacher'] + ", " + i['School Subject']['Monday'][1]['Subject'])
|
||||
recheck()
|
||||
elif now.strftime("%H:%M") == "8:50":
|
||||
for i in find_document:
|
||||
for b in array_username:
|
||||
bot.send_message(b, i['School Subject'][today][1]['Subject'])
|
||||
elif now.strftime("%H:%M") == "09:53":
|
||||
bot.send_message(b, str(i['School Subject']['Monday'][1]['Room']) + ", " + i['School Subject']['Monday'][1]['Teacher'] + ", " + str(i['School Subject']['Monday'][1]['Subject']) + "\n" + "Successiva: " + str(i['School Subject']['Monday'][2]['Room']) + ", " + i['School Subject']['Monday'][2]['Teacher'] + ", " + i['School Subject']['Monday'][2]['Subject'])
|
||||
recheck()
|
||||
elif now.strftime("%H:%M") == "9:50":
|
||||
for i in find_document:
|
||||
for b in array_username:
|
||||
bot.send_message(b, i['School Subject'][today][2]['Subject'])
|
||||
elif now.strftime("%H:%M") == "10:53":
|
||||
bot.send_message(b, str(i['School Subject']['Monday'][2]['Room']) + ", " + i['School Subject']['Monday'][2]['Teacher'] + ", " + str(i['School Subject']['Monday'][2]['Subject']) + "\n" + "Successiva: " + str(i['School Subject']['Monday'][3]['Room']) + ", " + i['School Subject']['Monday'][3]['Teacher'] + ", " + i['School Subject']['Monday'][3]['Subject'])
|
||||
recheck()
|
||||
elif now.strftime("%H:%M") == "11:05":
|
||||
for i in find_document:
|
||||
for b in array_username:
|
||||
bot.send_message(b, i['School Subject'][today][3]['Subject'])
|
||||
elif now.strftime("%H:%M") == "12:08":
|
||||
bot.send_message(b, str(i['School Subject']['Monday'][3]['Room']) + ", " + i['School Subject']['Monday'][3]['Teacher'] + ", " + str(i['School Subject']['Monday'][3]['Subject']) + "\n" + "Successiva: " + str(i['School Subject']['Monday'][4]['Room']) + ", " + i['School Subject']['Monday'][4]['Teacher'] + ", " + i['School Subject']['Monday'][4]['Subject'])
|
||||
recheck()
|
||||
elif now.strftime("%H:%M") == "12:05":
|
||||
for i in find_document:
|
||||
for b in array_username:
|
||||
bot.send_message(b, i['School Subject'][today][4]['Subject'])
|
||||
elif now.strftime("%H:%M") == "13:08":
|
||||
bot.send_message(b, str(i['School Subject']['Monday'][4]['Room']) + ", " + i['School Subject']['Monday'][4]['Teacher'] + ", " + str(i['School Subject']['Monday'][4]['Subject']) + "\n" + "Successiva: " + str(i['School Subject']['Monday'][5]['Room']) + ", " + i['School Subject']['Monday'][5]['Teacher'] + ", " + i['School Subject']['Monday'][5]['Subject'])
|
||||
recheck()
|
||||
elif now.strftime("%H:%M") == "13:05":
|
||||
for i in find_document:
|
||||
for b in array_username:
|
||||
bot.send_message(b, i['School Subject'][today][5]['Subject'])
|
||||
bot.send_message(b, str(i['School Subject']['Monday'][5]['Room']) + ", " + i['School Subject']['Monday'][5]['Teacher'] + ", " + str(i['School Subject']['Monday'][5]['Subject']))
|
||||
recheck()
|
||||
elif now.strftime("%H:%M") == "21:00":
|
||||
if tomorrow == "Sunday" or tomorrow == "Saturday":
|
||||
print("Nope")
|
||||
else:
|
||||
for i in find_document:
|
||||
for b in array_username:
|
||||
bot.send_message(b, i['School Subject'][tomorrow][0]['Subject'] + ", " + i['School Subject'][tomorrow][0]['Teacher'] + "\n" + i['School Subject'][tomorrow][1]['Subject'] + ", " + i['School Subject'][tomorrow][1]['Teacher'] + "\n" + i['School Subject'][tomorrow][2]['Subject'] + ", " + i['School Subject'][tomorrow][2]['Teacher'] + "\n" + i['School Subject'][tomorrow][3]['Subject'] + ", " + i['School Subject'][tomorrow][3]['Teacher'] + "\n" + i['School Subject'][tomorrow][4]['Subject'] + ", " + i['School Subject'][tomorrow][4]['Teacher'] + "\n" + i['School Subject'][tomorrow][5]['Subject'] + ", " + i['School Subject'][tomorrow][5]['Teacher'])
|
||||
else:
|
||||
recheck()
|
||||
|
||||
|
@ -90,5 +100,4 @@ now = datetime.datetime.now()
|
|||
t1 = threading.Thread(target=bot.polling).start()
|
||||
|
||||
while True:
|
||||
print(now.strftime("%H:%M"))
|
||||
schedule.run_pending()
|
||||
|
|
Loading…
Reference in New Issue