Now it doesn't crash anymore but it doesn't respond to other commands
This commit is contained in:
parent
d0b082239b
commit
394add3c4b
17
main.py
17
main.py
|
@ -170,14 +170,13 @@ def a():
|
|||
#schedule.every().thursday.do(freenow)
|
||||
|
||||
#Check for new games
|
||||
try:
|
||||
url = "https://api.plenusbot.xyz/epic_games?country=IT"
|
||||
global response
|
||||
response = requests.get(url).json()
|
||||
|
||||
# Title of current games
|
||||
current_games_title1 = response['currentGames'][0]['title']
|
||||
current_games_title2 = response['currentGames'][1]['title']
|
||||
|
||||
#Check first game
|
||||
search_game1 = collection.find_one({"Game 1" : current_games_title1})
|
||||
if search_game1 is None:
|
||||
#Send notification if title game is changed
|
||||
|
@ -188,15 +187,19 @@ def a():
|
|||
#If new game is changed recheck every 10 second
|
||||
print("The game is not changed")
|
||||
recheck_game()
|
||||
|
||||
except:
|
||||
print("Ghe se un problema")
|
||||
else:
|
||||
recheck_game()
|
||||
|
||||
def send_automatically1():
|
||||
logging.info("Triggered AUTOMATICALLY SEND MESSAGE.")
|
||||
#Connect to the api
|
||||
try:
|
||||
url = "https://api.plenusbot.xyz/epic_games?country=IT"
|
||||
global response
|
||||
response = requests.get(url).json()
|
||||
|
||||
#All information for first game
|
||||
current_games_title1 = response['currentGames'][0]['title'] # First title current games
|
||||
current_games_description1 = response['currentGames'][0]['description'] # First description current games
|
||||
current_games_startdate1 = response['currentGames'][0]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['startDate'] # Public release first game
|
||||
|
@ -231,6 +234,10 @@ def send_automatically1():
|
|||
|
||||
send_game2 = {"Game 2": current_games_title2}
|
||||
senddata = collection.update_one({'_id':ObjectId("6319c0ac2ffd38ae32cd9ffa")}, {"$set": send_game2}, upsert=False)
|
||||
except:
|
||||
print("Ghe se un problema")
|
||||
else:
|
||||
recheck_game()
|
||||
|
||||
schedule.every(10).seconds.do(recheck_game)
|
||||
bot.polling()
|
Loading…
Reference in New Issue