mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-06-25 19:03:56 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
12a6968ee0 | |||
8726785dc8 | |||
e9f629dee4 | |||
c9a838d368 |
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
A Microsoft reward automator, designed to work headless on any server.
|
A Microsoft reward automator, designed to work headless on any server.
|
||||||
Using a discord webhook or SQL to log points everyday.
|
Using a discord webhook or SQL to log points everyday.
|
||||||
Using Selenium and geckodriver.
|
Using Selenium and Geckodriver.
|
||||||
|
|
||||||
## If you're using docker (way easier)
|
## If you're using docker (way easier)
|
||||||
to use docker, run
|
to use docker, run
|
||||||
@ -12,14 +12,14 @@ sudo docker build .
|
|||||||
#copy the build id
|
#copy the build id
|
||||||
sudo docker run -ti --name MsRewards [build id]
|
sudo docker run -ti --name MsRewards [build id]
|
||||||
```
|
```
|
||||||
Then, fill the config and start the programm everydays with
|
Then, fill the config and start the program everyday with
|
||||||
```
|
```
|
||||||
sudo docker start MsRewards
|
sudo docker start MsRewards
|
||||||
```
|
```
|
||||||
|
|
||||||
## Other configuration
|
## Other configuration
|
||||||
|
|
||||||
To use the database, I recommand MySql, Create a database with the name you want and create a table `daily`, like the one from the image :
|
To use the database, I recommend MySql, Create a database with the name you want and create a table `daily`, like the one from the image :
|
||||||

|

|
||||||
|
|
||||||
You have to use the default world list (`sudo apt install wfrench`). The language is french by default, but you can change it if you want.
|
You have to use the default world list (`sudo apt install wfrench`). The language is french by default, but you can change it if you want.
|
||||||
|
36
V5.py
36
V5.py
@ -15,9 +15,8 @@ def printf(e):
|
|||||||
printf2(str(e), _mail)
|
printf2(str(e), _mail)
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# handle "panda"'s error: error while logging in preventing some task to be done
|
# handle "panda"'s error: error while logging in preventing some task to be done SadPanda.svg
|
||||||
# check that each card worked (lot of misses lately) -- test that -- don't crash at least
|
# check that each card worked (lot of misses lately) -- test that -- don't crash at least
|
||||||
# Fix l'affichage du compteur de custom_sleep
|
|
||||||
|
|
||||||
|
|
||||||
# create a webdriver
|
# create a webdriver
|
||||||
@ -85,9 +84,8 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
|
|||||||
file = File("screenshot.png")
|
file = File("screenshot.png")
|
||||||
embed.set_image(url="attachment://screenshot.png")
|
embed.set_image(url="attachment://screenshot.png")
|
||||||
embed.set_footer(text=_mail)
|
embed.set_footer(text=_mail)
|
||||||
webhookFailure.send(embed=embed, file=file)
|
webhookFailure.send(embed=embed, username="error", file=file, avatar_url = AVATAR_URL)
|
||||||
webhookFailure.send(file=File("page.html"))
|
webhookFailure.send(username="error", file=File("page.html"), avatar_url = AVATAR_URL)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# close the tab currently on and go back to the one first, or the one specified
|
# close the tab currently on and go back to the one first, or the one specified
|
||||||
@ -103,7 +101,7 @@ def play_quiz2(override=10) -> None:
|
|||||||
printf("starting play_quiz2")
|
printf("starting play_quiz2")
|
||||||
for j in range(override):
|
for j in range(override):
|
||||||
try:
|
try:
|
||||||
rgpd_popup(driver)
|
# rgpd_popup(driver)
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
page_html = driver.page_source
|
page_html = driver.page_source
|
||||||
secret_answer = search('IG:"([^"]+)"', page_html)[1] # variable used to calculate offset
|
secret_answer = search('IG:"([^"]+)"', page_html)[1] # variable used to calculate offset
|
||||||
@ -137,7 +135,7 @@ def play_quiz8():
|
|||||||
printf(f"play_quiz8 : start, override : {override}")
|
printf(f"play_quiz8 : start, override : {override}")
|
||||||
try:
|
try:
|
||||||
counter = 0
|
counter = 0
|
||||||
rgpd_popup(driver)
|
# rgpd_popup(driver)
|
||||||
for _ in range(override):
|
for _ in range(override):
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
correct_answers = []
|
correct_answers = []
|
||||||
@ -184,7 +182,7 @@ def play_quiz4(override=None):
|
|||||||
for i in range(override):
|
for i in range(override):
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
txt = driver.page_source
|
txt = driver.page_source
|
||||||
rgpd_popup(driver)
|
# rgpd_popup(driver)
|
||||||
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
|
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
|
||||||
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
|
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
|
||||||
try:
|
try:
|
||||||
@ -234,7 +232,7 @@ def all_cards(): # return to the main page and closes all other tabs
|
|||||||
driver.get("https://www.bing.com/rewardsapp/flyout")
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
||||||
reset(part2)
|
reset(part2)
|
||||||
|
|
||||||
def daily_cards(): # cartes de la premiere partie (renouvelées chaque jours).
|
def daily_cards(): # cartes de la premiere partie (renouvelée chaque jour).
|
||||||
try:
|
try:
|
||||||
# make sure that the daily area is expanded
|
# make sure that the daily area is expanded
|
||||||
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[0]
|
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[0]
|
||||||
@ -308,7 +306,7 @@ def all_cards(): # return to the main page and closes all other tabs
|
|||||||
|
|
||||||
try :
|
try :
|
||||||
#top_cards()
|
#top_cards()
|
||||||
print("top card not working really well right now. Disableing them")
|
print("top card not working really well right now. They are currently disabled")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(e)
|
log_error(e)
|
||||||
|
|
||||||
@ -368,7 +366,7 @@ def try_play(nom="inconnu"):
|
|||||||
if "bt_PollRadio" in driver.page_source:
|
if "bt_PollRadio" in driver.page_source:
|
||||||
try:
|
try:
|
||||||
printf("Poll detected")
|
printf("Poll detected")
|
||||||
rgpd_popup(driver)
|
#rgpd_popup(driver)
|
||||||
do_poll()
|
do_poll()
|
||||||
printf("Poll succeeded")
|
printf("Poll succeeded")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -384,12 +382,12 @@ def try_play(nom="inconnu"):
|
|||||||
|
|
||||||
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
|
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
|
||||||
printf("fidélité")
|
printf("fidélité")
|
||||||
rgpd_popup(driver)
|
#rgpd_popup(driver)
|
||||||
fidelity()
|
fidelity()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
printf(f"rien à faire sur la page {nom}")
|
printf(f"rien à faire sur la page {nom}")
|
||||||
rgpd_popup(driver)
|
# rgpd_popup(driver)
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
|
|
||||||
|
|
||||||
@ -468,14 +466,18 @@ def login(ldriver):
|
|||||||
printf("Timeout error occurred. \"normal\"....., maybe because of mismatch date ? ")
|
printf("Timeout error occurred. \"normal\"....., maybe because of mismatch date ? ")
|
||||||
log_error("Timeout error occurred. \"normal\"....., maybe because of mismatch date ?", ldriver, True) # TODO check this hypothesis
|
log_error("Timeout error occurred. \"normal\"....., maybe because of mismatch date ?", ldriver, True) # TODO check this hypothesis
|
||||||
else:
|
else:
|
||||||
log_error(e)
|
log_error(e, ldriver)
|
||||||
custom_sleep(20) # TODO : remplacer par un wait_element
|
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-rewards"]', 20, ldriver)
|
||||||
if ("account.microsoft.com" in ldriver.current_url) :
|
if ("account.microsoft.com" in ldriver.current_url) :
|
||||||
ldriver.get("https://bing.com")
|
ldriver.get("https://bing.com")
|
||||||
custom_sleep(5)
|
custom_sleep(5)
|
||||||
ldriver.refresh()
|
ldriver.refresh()
|
||||||
rgpd_popup(ldriver)
|
rgpd_popup(ldriver) # Ultra important
|
||||||
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
||||||
|
#if "SadPanda.svg" in ldriver.page_source :
|
||||||
|
# log_error('test SadPanda before', ldriver)
|
||||||
|
# driver.execute_script("location.reload(true);")
|
||||||
|
# log_error('test SadPanda after', ldriver)
|
||||||
if not('>Tableau de bord' in ldriver.page_source):
|
if not('>Tableau de bord' in ldriver.page_source):
|
||||||
try :
|
try :
|
||||||
ldriver.find_element(By.CSS_SELECTOR, "[h='ID=RewardsFlyout,2.1']").click()
|
ldriver.find_element(By.CSS_SELECTOR, "[h='ID=RewardsFlyout,2.1']").click()
|
||||||
@ -847,7 +849,7 @@ def daily_routine(custom = False):
|
|||||||
|
|
||||||
|
|
||||||
def dev():
|
def dev():
|
||||||
pass
|
log_error("test")
|
||||||
|
|
||||||
|
|
||||||
def CustomStart(Credentials):
|
def CustomStart(Credentials):
|
||||||
|
@ -82,7 +82,7 @@ parser.add_argument(
|
|||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--updated",
|
"--version",
|
||||||
help="display a message on discord to tell that the bot have been updated",
|
help="display a message on discord to tell that the bot have been updated",
|
||||||
dest="update_version",
|
dest="update_version",
|
||||||
default="None"
|
default="None"
|
||||||
@ -131,6 +131,10 @@ DISCORD_SUCCESS_LINK = config["DISCORD"]["successlink"]
|
|||||||
DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"]
|
DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"]
|
||||||
DISCORD_ENABLED_ERROR = config["DISCORD"]["DiscordErrorEnabled"] == "True"
|
DISCORD_ENABLED_ERROR = config["DISCORD"]["DiscordErrorEnabled"] == "True"
|
||||||
DISCORD_ENABLED_SUCCESS = config["DISCORD"]["DiscordSuccessEnabled"]== "True"
|
DISCORD_ENABLED_SUCCESS = config["DISCORD"]["DiscordSuccessEnabled"]== "True"
|
||||||
|
try :
|
||||||
|
AVATAR_URL = config["OTHER"]["avatar"]== "True"
|
||||||
|
except :
|
||||||
|
AVATAR_URL = "https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp"
|
||||||
|
|
||||||
if DISCORD_ENABLED_ERROR:
|
if DISCORD_ENABLED_ERROR:
|
||||||
webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter())
|
webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter())
|
||||||
|
@ -31,5 +31,5 @@ usr = root
|
|||||||
pwd = password
|
pwd = password
|
||||||
|
|
||||||
[OTHER]
|
[OTHER]
|
||||||
|
avatar = https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp
|
||||||
ipv6 = False
|
ipv6 = False
|
Reference in New Issue
Block a user