From 3e3b9e854d0b4490aee9c4a125ba395b790ca83b Mon Sep 17 00:00:00 2001 From: Stefano Assenzo Date: Mon, 5 Sep 2022 16:59:09 +0200 Subject: [PATCH] Now third game work! --- main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 3d66779..bedd534 100644 --- a/main.py +++ b/main.py @@ -44,9 +44,17 @@ def comingsoon(message): future_games_startdate2 = response['nextGames'][1]['promotions']['upcomingPromotionalOffers'][0]['promotionalOffers'][0]['startDate'] future_games_price2 = response['nextGames'][1]['price']['totalPrice']['fmtPrice']['originalPrice'] - #image_futuregames3 = response['nextGames'][0]['keyImages'][2]['url'] # Third image future games - #future_games3 = response['nextGames'][2]['title'] # Third title future games - #future_games_description3 = response['nextGames'][2]['description'] # Third description future games + try: + image_futuregames3 = response['nextGames'][0]['keyImages'][2]['url'] # Third image future games + future_games3 = response['nextGames'][2]['title'] # Third title future games + future_games_description3 = response['nextGames'][2]['description'] # Third description future games + future_games_startdate3 = response['nextGames'][1]['promotions']['upcomingPromotionalOffers'][0]['promotionalOffers'][0]['startDate'] + future_games_price3 = response['nextGames'][1]['price']['totalPrice']['fmtPrice']['originalPrice'] + title_description_3 = future_games3 + "\n\nAbout:\n" + future_games_description3 + "\n" + "\nStart Date:\n" + future_games_startdate3 + "\n" + "\nPrice:\n" + future_games_price3 + " → " + "Free" # Send title, description, start date and price second future game + img_3 = bot.send_photo(message.chat.id, image_futuregames3) # Send image third future games + send_message = bot.send_message(chat_id, title_description_2, parse_mode="HTML") # Send all + except IndexError: + print("No third game") #Send notification to user title_description_1 = future_games1 + "\n\nAbout:\n" + future_games_description1 + "\n" + "\nStart Date:\n" + future_games_startdate1 + "\n" + "\nPrice:\n" + future_games_price1 + " → " + "Free" # Send title, description, start date and price first future game @@ -56,4 +64,5 @@ def comingsoon(message): title_description_2 = future_games2 + "\n\nAbout:\n" + future_games_description2 + "\n" + "\nStart Date:\n" + future_games_startdate2 + "\n" + "\nPrice:\n" + future_games_price2 + " → " + "Free" # Send title, description, start date and price second future game img_2 = bot.send_photo(message.chat.id, image_futuregames2) # Send image second future games send_message = bot.send_message(chat_id, title_description_2, parse_mode="HTML") # Send all + bot.polling() \ No newline at end of file