Change URL
This commit is contained in:
parent
2256b7b3c6
commit
b66ae49f67
|
@ -7,27 +7,21 @@ def freegame_command(message, bot):
|
|||
url = "https://api.plenusbot.xyz/epic_games?country=IT" #URL API
|
||||
response = requests.get(url).json() #API in JSON
|
||||
#Take data from API (Current Game 1)
|
||||
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_currentgames1 = response['games'][0]['mainImage'] # First image current games
|
||||
current_games1 = response['games'][0]['title'] # First title current games
|
||||
current_games_description1 = response['games'][0]['description'] # First description current games
|
||||
#Send notification to user (Current Game 1)
|
||||
title_description_1 = current_games1 + "\n\n<b>About:</b>\n" + current_games_description1 + "\n" + "\n<b>Start Date:</b>\n" + current_games_startdate1 + "\n" + "\n<b>End Date:</b>\n" + current_games_endate1 + "\n" + "\n<b>Price:</b>\n" + current_games_price1 + " → " + "Free" # Send title, description, start date and price first current game
|
||||
title_description_1 = current_games1 + "\n\n<b>About:</b>\n" + current_games_description1 # 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
|
||||
|
||||
try:
|
||||
#Take data from API (Current Game 2)
|
||||
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']
|
||||
image_currentgames2 = response['games'][1]['mainImage'] # First image current games
|
||||
current_games2 = response['games'][1]['title'] # First title current games
|
||||
current_games_description2 = response['games'][1]['description'] # First description current games
|
||||
|
||||
title_description_2 = current_games2 + "\n\n<b>About:</b>\n" + current_games_description2 + "\n" + "\n<b>Start Date:</b>\n" + current_games_startdate2 + "\n" + "\n<b>End Date:</b>\n" + current_games_endate2 + "\n" + "\n<b>Price:</b>\n" + current_games_price2 + " → " + "Free" # Send title, description, start date and price second current game
|
||||
title_description_2 = current_games2 + "\n\n<b>About:</b>\n" + current_games_description2 # 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
|
||||
except:
|
||||
|
@ -36,14 +30,12 @@ def freegame_command(message, bot):
|
|||
#Try search third game
|
||||
try:
|
||||
#Take data from API (Current Game 3)
|
||||
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']
|
||||
image_currentgames3 = response['games'][2]['mainImage'] # First image current games
|
||||
current_games3 = response['games'][2]['title'] # First title current games
|
||||
current_games_description3 = response['games'][2]['description'] # First description current games
|
||||
|
||||
#Send notification to user (Current Game 3)
|
||||
title_description_3 = current_games3 + "\n\n<b>About:</b>\n" + current_games_description3 + "\n" + "\n<b>Start Date:</b>\n" + current_games_startdate3 + "\n" + "\n<b>End Date:</b>\n" + current_games_endate3 + "\n" + "\n<b>Price:</b>\n" + current_games_price3 + " → " + "Free" # Send title, description, start date and price second current game
|
||||
title_description_3 = current_games3 + "\n\n<b>About:</b>\n" + current_games_description3 # 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:
|
||||
|
|
|
@ -11,12 +11,12 @@ def recheck_game(collection_game, collection_id, bot):
|
|||
def a(collection_game, collection_id, bot):
|
||||
try:
|
||||
#Connect to API
|
||||
url = "https://api.plenusbot.xyz/epic_games?country=IT" #URL API
|
||||
url = "https://minty.apexie.eu/v1/epicfreegames" #URL API
|
||||
response = requests.get(url).json() #API in JSON
|
||||
|
||||
# Title of current games
|
||||
try:
|
||||
current_games_title1 = response['currentGames'][0]['title'] #Title of first game
|
||||
current_games_title1 = response['games'][0]['title'] #Title of first game
|
||||
search_game1 = collection_game.find_one({"Game 1": current_games_title1}) #Search game1 in MongoDB
|
||||
|
||||
if search_game1 is None: #If game1 is not in MongoDB send notification
|
||||
|
@ -31,7 +31,7 @@ def a(collection_game, collection_id, bot):
|
|||
#recheck_game(collection_game, collection_id, bot)
|
||||
|
||||
try:
|
||||
current_games_title2 = response['currentGames'][1]['title'] #Title of second game
|
||||
current_games_title2 = response['games'][1]['title'] #Title of second game
|
||||
search_game2 = collection_game.find_one({"Game 2" : current_games_title2}) #Search game2 in MongoDB
|
||||
if search_game2 is None: #If game2 is not in MongoDB send notification
|
||||
#Send notification if title game is changed
|
||||
|
@ -43,7 +43,7 @@ def a(collection_game, collection_id, bot):
|
|||
#recheck_game(collection_game, collection_id, bot)
|
||||
|
||||
try:
|
||||
current_games_title3 = response['currentGames'][2]['title']
|
||||
current_games_title3 = response['games'][2]['title']
|
||||
search_game3 = collection_game.find_one({"Game 3" : current_games_title3})
|
||||
if search_game3 is None: #If game2 is not in MongoDB send notification
|
||||
#Send notification if title game is changed
|
||||
|
|
|
@ -6,23 +6,20 @@ def notification_game1(collection_game, collection_id, bot):
|
|||
try:
|
||||
print("Try to send first game")
|
||||
|
||||
url = "https://api.plenusbot.xyz/epic_games?country=IT"
|
||||
url = "https://minty.apexie.eu/v1/epicfreegames"
|
||||
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
|
||||
current_games_endate1 = response['currentGames'][0]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['endDate'] # End public release first game
|
||||
current_games_price1 = response['currentGames'][0]['price']['totalPrice']['fmtPrice']['originalPrice']
|
||||
current_games_images1 = response['currentGames'][0]['keyImages'][0]['url'] # First image current games
|
||||
current_games_title1 = response['games'][0]['title'] # First title current games
|
||||
current_games_description1 = response['games'][0]['description'] # First description current games
|
||||
current_games_images1 = response['games'][0]['mainImage'] # First image current games
|
||||
|
||||
collection_find_username = list(collection_id.find({}, {"username": 1,})) #Find all username in collection
|
||||
array_username = list(collection_find_username[0]['username']) #Get just the array
|
||||
|
||||
for i in array_username:
|
||||
#Send first and second message when the free game title change
|
||||
title_description_1 = current_games_title1 + "\n\n<b>About:</b>\n" + current_games_description1 + "\n" + "\n<b>Start Date:</b>\n" + current_games_startdate1 + "\n" + "\n<b>End Date:</b>\n" + current_games_endate1 + "\n" + "\n<b>Price:</b>\n" + current_games_price1 + " → " + "Free" # Send title, description, start date and price first current game
|
||||
title_description_1 = current_games_title1 + "\n\n<b>About:</b>\n" + current_games_description1 # Send title, description, start date and price first current game
|
||||
img_1 = bot.send_photo(i, current_games_images1) # Send image first current games
|
||||
send_message = bot.send_message(i, title_description_1, parse_mode="HTML") # Send all
|
||||
|
||||
|
@ -39,17 +36,14 @@ def notification_game2(collection_game, collection_id, bot,):
|
|||
try:
|
||||
print("Try to send second game")
|
||||
#All information for second game
|
||||
current_games_title2 = response['currentGames'][1]['title'] # Second title current game
|
||||
current_games_images2 = response['currentGames'][1]['keyImages'][0]['url'] # Second image current game
|
||||
current_games_description2 = response['currentGames'][1]['description'] # Second description current game
|
||||
current_games_startdate2 = response['currentGames'][1]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['startDate'] #Public release second game
|
||||
current_games_endate2 = response['currentGames'][1]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['endDate'] # End public release second game
|
||||
current_games_price2 = response['currentGames'][1]['price']['totalPrice']['fmtPrice']['originalPrice'] # Original price second game
|
||||
current_games_title2 = response['games'][1]['title'] # Second title current game
|
||||
current_games_images2 = response['games'][1]['mainImage'] # Second image current game
|
||||
current_games_description2 = response['games'][1]['description'] # Second description current game
|
||||
|
||||
collection_find_username = list(collection_id.find({}, {"username": 1,})) #Find all username in collection
|
||||
array_username = list(collection_find_username[1]['username']) #Get the array
|
||||
for i in array_username:
|
||||
title_description_2 = current_games_title2 + "\n\n<b>About:</b>\n" + current_games_description2 + "\n" + "\n<b>Start Date:</b>\n" + current_games_startdate2 + "\n" + "\n<b>End Date:</b>\n" + current_games_endate2 + "\n" + "\n<b>Price:</b>\n" + current_games_price2 + " → " + "Free" # Send title, description, start date and price second current game
|
||||
title_description_2 = current_games_title2 + "\n\n<b>About:</b>\n" + current_games_description2 # Send title, description, start date and price second current game
|
||||
img_2 = bot.send_photo(i, current_games_images2) # Send image second current games
|
||||
send_message = bot.send_message(i, title_description_2, parse_mode="HTML") # Send all
|
||||
|
||||
|
@ -66,17 +60,14 @@ def notification_game3(collection_game, collection_id, bot,):
|
|||
try:
|
||||
print("Try to send third game")
|
||||
#All information for second game
|
||||
current_games_title3 = response['currentGames'][1]['title'] # Third title current game
|
||||
current_games_images3 = response['currentGames'][1]['keyImages'][0]['url'] # Third image current game
|
||||
current_games_description3 = response['currentGames'][1]['description'] # Third description current game
|
||||
current_games_startdate3 = response['currentGames'][1]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['startDate'] #Public release Third game
|
||||
current_games_endate3 = response['currentGames'][1]['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['endDate'] # End public release Third game
|
||||
current_games_price3 = response['currentGames'][1]['price']['totalPrice']['fmtPrice']['originalPrice'] # Original price Third game
|
||||
current_games_title3 = response['games'][1]['title'] # Third title current game
|
||||
current_games_images3 = response['games'][1]['mainImage'] # Third image current game
|
||||
current_games_description3 = response['games'][1]['description'] # Third description current game
|
||||
|
||||
collection_find_username = list(collection_id.find({}, {"username": 1,})) #Find all username in collection
|
||||
array_username = list(collection_find_username[1]['username']) #Get the array
|
||||
for i in array_username:
|
||||
title_description_3 = current_games_title3 + "\n\n<b>About:</b>\n" + current_games_description3 + "\n" + "\n<b>Start Date:</b>\n" + current_games_startdate3 + "\n" + "\n<b>End Date:</b>\n" + current_games_endate3 + "\n" + "\n<b>Price:</b>\n" + current_games_price3 + " → " + "Free" # Send title, description, start date and price Third current game
|
||||
title_description_3 = current_games_title3 + "\n\n<b>About:</b>\n" + current_games_description3 # Send title, description, start date and price Third current game
|
||||
img_3 = bot.send_photo(i, current_games_images3) # Send image Third current games
|
||||
send_message = bot.send_message(i, title_description_3, parse_mode="HTML") # Send all
|
||||
|
||||
|
|
Loading…
Reference in New Issue