daily_challenge working now
This commit is contained in:
parent
b99a1247d2
commit
88991c52cb
@ -4,4 +4,5 @@ APScheduler~=3.9.1
|
|||||||
SQLAlchemy~=1.4.36
|
SQLAlchemy~=1.4.36
|
||||||
pymysql==1.0.2
|
pymysql==1.0.2
|
||||||
requests~=2.27.1
|
requests~=2.27.1
|
||||||
beautifulsoup4~=4.11.1
|
beautifulsoup4~=4.11.1
|
||||||
|
pandas~=1.4.1
|
@ -6,4 +6,4 @@ BOT_API_KEY=
|
|||||||
DATABASE_CONNECTION=mysql+pymysql://scott:tiger@localhost/foo?check_same_thread=False
|
DATABASE_CONNECTION=mysql+pymysql://scott:tiger@localhost/foo?check_same_thread=False
|
||||||
|
|
||||||
# SQLite
|
# SQLite
|
||||||
# DATABASE_CONNECTION=sqlite:///db.db
|
# DATABASE_CONNECTION=sqlite:///db.db?check_same_thread=False
|
@ -10,13 +10,14 @@ __license__ = "None"
|
|||||||
import sys
|
import sys
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
import time
|
import time
|
||||||
|
import pandas
|
||||||
|
|
||||||
from bot import bot
|
from bot import bot
|
||||||
from db import User, session, Product
|
from db import User, session, Product
|
||||||
|
|
||||||
|
|
||||||
CHALLENGE_READY = "0 10 * * *"
|
CHALLENGE_READY = "0 8 * * *"
|
||||||
CHALLENGE_OVER = "0 20 * * *"
|
CHALLENGE_OVER = "0 22 * * *"
|
||||||
|
|
||||||
def start_challenges():
|
def start_challenges():
|
||||||
"""Start the daily challenges, read the crontag codes and send messages
|
"""Start the daily challenges, read the crontag codes and send messages
|
||||||
@ -49,10 +50,10 @@ def send_current_event(str_event):
|
|||||||
Args:
|
Args:
|
||||||
str_event (String): event to send
|
str_event (String): event to send
|
||||||
"""
|
"""
|
||||||
all_users = session.query(User.telegram_id).all()
|
all_users = pandas.DataFrame(session.query(User.telegram_id).all())
|
||||||
|
|
||||||
if str_event == "start":
|
if str_event == "start":
|
||||||
for element in all_users:
|
for element in all_users["telegram_id"]:
|
||||||
bot.send_message(chat_id=int(element), text="Todays challenge is available!\nTry /daily to give it a try :)")
|
bot.send_message(chat_id=int(element), text="Todays challenge is available!\nTry /daily to give it a try :)")
|
||||||
elif str_event == "over":
|
elif str_event == "over":
|
||||||
for element in all_users:
|
for element in all_users:
|
||||||
@ -63,8 +64,10 @@ def send_current_event(str_event):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
test = session.query(User.telegram_id).all()
|
test = pandas.DataFrame(session.query(User.telegram_id).all())
|
||||||
print(test)
|
for element in test["telegram_id"]:
|
||||||
|
print(element)
|
||||||
|
|
||||||
start_challenges()
|
start_challenges()
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
Loading…
Reference in New Issue
Block a user