From 1611b1add4f2ee7a390b3f5af231b00b534a616f Mon Sep 17 00:00:00 2001 From: Stefano Assenzo Date: Mon, 5 Sep 2022 17:18:59 +0200 Subject: [PATCH] So i add current games command --- main.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/main.py b/main.py index bedd534..daa0548 100644 --- a/main.py +++ b/main.py @@ -65,4 +65,46 @@ def comingsoon(message): 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 +#Command /freenow +@bot.message_handler(commands=['freenow']) +def freenow(message): + chat_id = message.chat.id + url = "https://api.plenusbot.xyz/epic_games?country=IT" + response = requests.get(url).json() + image_currentgames1 = response['currentGames'][0]['keyImages'][0]['url'] # First image current games + current_games1 = 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'] + current_games_endate1 = response['currentGames'][0]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['endDate'] + current_games_price1 = response['currentGames'][0]['price']['totalPrice']['fmtPrice']['originalPrice'] + + image_currentgames2 = response['currentGames'][1]['keyImages'][0]['url'] # First image current games + current_games2 = response['currentGames'][1]['title'] # First title current games + current_games_description2 = response['currentGames'][1]['description'] # First description current games + current_games_startdate2 = response['currentGames'][1]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['startDate'] + current_games_endate2 = response['currentGames'][1]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['endDate'] + current_games_price2 = response['currentGames'][1]['price']['totalPrice']['fmtPrice']['originalPrice'] + + #Send notification to user + title_description_1 = current_games1 + "\n\nAbout:\n" + current_games_description1 + "\n" + "\nStart Date:\n" + current_games_startdate1 + "\n" + "\nEnd Date:\n" + current_games_endate1 + "\n" + "\nPrice:\n" + current_games_price1 + " → " + "Free" # Send title, description, start date and price first current game + img_1 = bot.send_photo(message.chat.id, image_currentgames1) # Send image first current games + send_message = bot.send_message(chat_id, title_description_1, parse_mode="HTML") # Send all + + title_description_2 = current_games2 + "\n\nAbout:\n" + current_games_description2 + "\n" + "\nStart Date:\n" + current_games_startdate2 + "\n" + "\nEnd Date:\n" + current_games_endate2 + "\n" + "\nPrice:\n" + current_games_price2 + " → " + "Free" # Send title, description, start date and price second current game + img_2 = bot.send_photo(message.chat.id, image_currentgames2) # Send image second current games + send_message = bot.send_message(chat_id, title_description_2, parse_mode="HTML") # Send all + + try: + image_currentgames3 = response['currentGames'][2]['keyImages'][0]['url'] # First image current games + current_games3 = response['currentGames'][2]['title'] # First title current games + current_games_description3 = response['currentGames'][2]['description'] # First description current games + current_games_startdate3 = response['currentGames'][2]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['startDate'] + current_games_endate3 = response['currentGames'][2]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['endDate'] + current_games_price3 = response['currentGames'][2]['price']['totalPrice']['fmtPrice']['originalPrice'] + title_description_3 = current_games3 + "\n\nAbout:\n" + current_games_description3 + "\n" + "\nStart Date:\n" + current_games_startdate3 + "\n" + "\nEnd Date:\n" + current_games_endate3 + "\n" + "\nPrice:\n" + current_games_price3 + " → " + "Free" # Send title, description, start date and price second current game + img_3 = bot.send_photo(message.chat.id, image_currentgames3) # Send image second current games + send_message = bot.send_message(chat_id, title_description_3, parse_mode="HTML") # Send all + except IndexError: + print("No third game") + bot.polling() \ No newline at end of file