Compare commits

...

3 Commits

Author SHA1 Message Date
Stefano Assenzo d8db86a33d
ehi 2023-03-06 16:07:05 +00:00
Stefano Assenzo f19d664646
So now? 2023-03-06 16:06:59 +00:00
Stefano Assenzo 2c78f7ed1e
Everything should be right now 2023-03-06 16:02:21 +00:00
3 changed files with 17 additions and 17 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ test.py
school_time.xlsx school_time.xlsx
venv venv
screenshot.png screenshot.png
Dockerfile

View File

@ -6,7 +6,6 @@ import datetime
import schedule import schedule
import pymongo import pymongo
import urllib import urllib
import time
import os import os
load_dotenv() load_dotenv()
@ -38,10 +37,6 @@ def subscribe(message):
) )
bot.send_message(message.chat.id, "You are subscribed") bot.send_message(message.chat.id, "You are subscribed")
def recheck():
time.sleep(60)
send_notification()
def send_notification(): def send_notification():
today = datetime.datetime.today().strftime('%A') today = datetime.datetime.today().strftime('%A')
tomorrow = (datetime.datetime.today() + datetime.timedelta(days=1)).strftime('%A') tomorrow = (datetime.datetime.today() + datetime.timedelta(days=1)).strftime('%A')
@ -59,32 +54,26 @@ def send_notification():
for i in find_document: for i in find_document:
for b in array_username: for b in array_username:
bot.send_message(b, str(i['School Subject'][today][0]['Room']) + ", " + i['School Subject'][today][0]['Teacher'] + ", " + i['School Subject'][today][0]['Subject'] + "\n" + "Successiva: " + str(i['School Subject'][today][1]['Room']) + ", " + i['School Subject'][today][1]['Teacher'] + ", " + i['School Subject'][today][1]['Subject']) bot.send_message(b, str(i['School Subject'][today][0]['Room']) + ", " + i['School Subject'][today][0]['Teacher'] + ", " + i['School Subject'][today][0]['Subject'] + "\n" + "Successiva: " + str(i['School Subject'][today][1]['Room']) + ", " + i['School Subject'][today][1]['Teacher'] + ", " + i['School Subject'][today][1]['Subject'])
recheck()
elif now.strftime("%H:%M") == "08:50": elif now.strftime("%H:%M") == "08:50":
for i in find_document: for i in find_document:
for b in array_username: for b in array_username:
bot.send_message(b, str(i['School Subject'][today][1]['Room']) + ", " + i['School Subject'][today][1]['Teacher'] + ", " + str(i['School Subject'][today][1]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][2]['Room']) + ", " + i['School Subject'][today][2]['Teacher'] + ", " + i['School Subject'][today][2]['Subject']) bot.send_message(b, str(i['School Subject'][today][1]['Room']) + ", " + i['School Subject'][today][1]['Teacher'] + ", " + str(i['School Subject'][today][1]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][2]['Room']) + ", " + i['School Subject'][today][2]['Teacher'] + ", " + i['School Subject'][today][2]['Subject'])
recheck()
elif now.strftime("%H:%M") == "09:50": elif now.strftime("%H:%M") == "09:50":
for i in find_document: for i in find_document:
for b in array_username: for b in array_username:
bot.send_message(b, str(i['School Subject'][today][2]['Room']) + ", " + i['School Subject'][today][2]['Teacher'] + ", " + str(i['School Subject'][today][2]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][3]['Room']) + ", " + i['School Subject'][today][3]['Teacher'] + ", " + i['School Subject'][today][3]['Subject']) bot.send_message(b, str(i['School Subject'][today][2]['Room']) + ", " + i['School Subject'][today][2]['Teacher'] + ", " + str(i['School Subject'][today][2]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][3]['Room']) + ", " + i['School Subject'][today][3]['Teacher'] + ", " + i['School Subject'][today][3]['Subject'])
recheck()
elif now.strftime("%H:%M") == "11:05": elif now.strftime("%H:%M") == "11:05":
for i in find_document: for i in find_document:
for b in array_username: for b in array_username:
bot.send_message(b, str(i['School Subject'][today][3]['Room']) + ", " + i['School Subject'][today][3]['Teacher'] + ", " + str(i['School Subject'][today][3]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][4]['Room']) + ", " + i['School Subject'][today][4]['Teacher'] + ", " + i['School Subject'][today][4]['Subject']) bot.send_message(b, str(i['School Subject'][today][3]['Room']) + ", " + i['School Subject'][today][3]['Teacher'] + ", " + str(i['School Subject'][today][3]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][4]['Room']) + ", " + i['School Subject'][today][4]['Teacher'] + ", " + i['School Subject'][today][4]['Subject'])
recheck()
elif now.strftime("%H:%M") == "12:05": elif now.strftime("%H:%M") == "12:05":
for i in find_document: for i in find_document:
for b in array_username: for b in array_username:
bot.send_message(b, str(i['School Subject'][today][4]['Room']) + ", " + i['School Subject'][today][4]['Teacher'] + ", " + str(i['School Subject'][today][4]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][5]['Room']) + ", " + i['School Subject'][today][5]['Teacher'] + ", " + i['School Subject'][today][5]['Subject']) bot.send_message(b, str(i['School Subject'][today][4]['Room']) + ", " + i['School Subject'][today][4]['Teacher'] + ", " + str(i['School Subject'][today][4]['Subject']) + "\n" + "Successiva: " + str(i['School Subject'][today][5]['Room']) + ", " + i['School Subject'][today][5]['Teacher'] + ", " + i['School Subject'][today][5]['Subject'])
recheck()
elif now.strftime("%H:%M") == "13:05": elif now.strftime("%H:%M") == "13:05":
for i in find_document: for i in find_document:
for b in array_username: for b in array_username:
bot.send_message(b, str(i['School Subject'][today][5]['Room']) + ", " + i['School Subject'][today][5]['Teacher'] + ", " + str(i['School Subject'][today][5]['Subject'])) bot.send_message(b, str(i['School Subject'][today][5]['Room']) + ", " + i['School Subject'][today][5]['Teacher'] + ", " + str(i['School Subject'][today][5]['Subject']))
recheck()
elif now.strftime("%H:%M") == "21:00": elif now.strftime("%H:%M") == "21:00":
if tomorrow == "Sunday" or tomorrow == "Saturday": if tomorrow == "Sunday" or tomorrow == "Saturday":
print("Nope") print("Nope")
@ -92,10 +81,14 @@ def send_notification():
for i in find_document: for i in find_document:
for b in array_username: 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']) 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()
schedule.every().day.at("07:50").do(send_notification) schedule.every().day.at("07:50").do(send_notification)
schedule.every().day.at("08:50").do(send_notification)
schedule.every().day.at("09:50").do(send_notification)
schedule.every().day.at("11:05").do(send_notification)
schedule.every().day.at("12:05").do(send_notification)
schedule.every().day.at("13:05").do(send_notification)
schedule.every().day.at("21:00").do(send_notification)
now = datetime.datetime.now() now = datetime.datetime.now()
t1 = threading.Thread(target=bot.polling).start() t1 = threading.Thread(target=bot.polling).start()

View File

@ -1,3 +1,9 @@
pymongo==4.3.3
urllib3==1.26.13
python-dotenv==0.21.0
schedule==1.1.0
telebot==0.0.5
pybson==0.5.9
pybson==0.5.9 pybson==0.5.9
python-dotenv==0.21.0 python-dotenv==0.21.0
telebot==0.0.5 telebot==0.0.5