Now check if you have already redeemed the game.
This commit is contained in:
parent
276a85a8d1
commit
87145d1058
|
@ -0,0 +1,2 @@
|
||||||
|
game1.txt
|
||||||
|
game2.txt
|
67
index.py
67
index.py
|
@ -3,33 +3,58 @@ import requests
|
||||||
#Create Windows notification
|
#Create Windows notification
|
||||||
from win10toast import ToastNotifier
|
from win10toast import ToastNotifier
|
||||||
|
|
||||||
#URL API
|
import time
|
||||||
url = "https://api.plenusbot.xyz/epic_games?country=IT"
|
|
||||||
response = requests.get(url).json()
|
|
||||||
# Title of current games
|
|
||||||
current_games_title1 = response['currentGames'][0]['title']
|
|
||||||
current_games_title2 = response['currentGames'][1]['title']
|
|
||||||
fix_1 = "["+"'"+current_games_title1+"'""]"
|
|
||||||
fix_2 = "["+"'"+current_games_title2+"'""]"
|
|
||||||
|
|
||||||
#Generate Windows notification
|
def recheck_game():
|
||||||
def notification():
|
#In 10 seconds I will double check if you have already redeemed the game.
|
||||||
|
time.sleep(10)
|
||||||
|
check_game()
|
||||||
|
|
||||||
|
def send_notification1():
|
||||||
|
print("Send first game notification")
|
||||||
#Icon file
|
#Icon file
|
||||||
filename = 'epic_games.ico'
|
filename = 'epic_games.ico'
|
||||||
#Create notification on Windows
|
#Create notification on Windows
|
||||||
toast = ToastNotifier()
|
toast = ToastNotifier()
|
||||||
toast.show_toast(title="New games!", msg="The new game is: " + current_games_title1 , icon_path=filename,duration=10,threaded=False)
|
toast.show_toast(title="New games!", msg="The new game is: " + current_games_title1 , icon_path=filename,duration=10,threaded=False)
|
||||||
|
with open('game1.txt', 'w') as f:
|
||||||
|
f.write(current_games_title1)
|
||||||
|
|
||||||
#Check if i already redeem the game
|
def send_notification2():
|
||||||
with open('game1.txt') as f:
|
print("Send second game notification")
|
||||||
lines = f.readlines()
|
#Icon file
|
||||||
if fix_1 == lines:
|
filename = 'epic_games.ico'
|
||||||
notification()
|
#Create notification on Windows
|
||||||
|
toast = ToastNotifier()
|
||||||
|
toast.show_toast(title="New games!", msg="The new game is: " + current_games_title2 , icon_path=filename,duration=10,threaded=False)
|
||||||
|
with open('game2.txt', 'w') as f:
|
||||||
|
f.write(current_games_title2)
|
||||||
|
|
||||||
|
|
||||||
|
def check_game():
|
||||||
|
print("Connect to the api")
|
||||||
|
url = "https://api.plenusbot.xyz/epic_games?country=IT"
|
||||||
|
response = requests.get(url).json()
|
||||||
|
# Title of current games
|
||||||
|
global current_games_title1
|
||||||
|
current_games_title1 = response['currentGames'][0]['title']
|
||||||
|
global current_games_title2
|
||||||
|
current_games_title2 = response['currentGames'][1]['title']
|
||||||
|
#Check first game
|
||||||
|
print("Check if you have already redeemed the game - First game")
|
||||||
|
f1 = open("game1.txt", "r")
|
||||||
|
if f1.read() == current_games_title1:
|
||||||
|
recheck_game()
|
||||||
else:
|
else:
|
||||||
print("Nope")
|
print("Send notification for first game")
|
||||||
with open('game2.txt') as f:
|
send_notification1()
|
||||||
lines = f.readlines()
|
#Check second game
|
||||||
if fix_2 == lines:
|
print("Check if you have already redeemed the game - Second game")
|
||||||
notification()
|
f2 = open("game2.txt", "r")
|
||||||
|
if f2.read() == current_games_title2:
|
||||||
|
recheck_game()
|
||||||
else:
|
else:
|
||||||
print("Nope")
|
print("Send notification for second game")
|
||||||
|
send_notification2()
|
||||||
|
|
||||||
|
check_game()
|
Loading…
Reference in New Issue