4 Commits

6 changed files with 76 additions and 43 deletions

28
V5.py
View File

@ -85,9 +85,8 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
file = File("screenshot.png")
embed.set_image(url="attachment://screenshot.png")
embed.set_footer(text=_mail)
webhookFailure.send(embed=embed, file=file)
webhookFailure.send(file=File("page.html"))
webhookFailure.send(embed=embed, username="error", file=file, avatar_url = AVATAR_URL)
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
@ -103,7 +102,7 @@ def play_quiz2(override=10) -> None:
printf("starting play_quiz2")
for j in range(override):
try:
rgpd_popup(driver)
# rgpd_popup(driver)
custom_sleep(uniform(3, 5))
page_html = driver.page_source
secret_answer = search('IG:"([^"]+)"', page_html)[1] # variable used to calculate offset
@ -137,7 +136,7 @@ def play_quiz8():
printf(f"play_quiz8 : start, override : {override}")
try:
counter = 0
rgpd_popup(driver)
# rgpd_popup(driver)
for _ in range(override):
custom_sleep(uniform(3, 5))
correct_answers = []
@ -184,7 +183,7 @@ def play_quiz4(override=None):
for i in range(override):
custom_sleep(uniform(3, 5))
txt = driver.page_source
rgpd_popup(driver)
# rgpd_popup(driver)
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
try:
@ -368,7 +367,7 @@ def try_play(nom="inconnu"):
if "bt_PollRadio" in driver.page_source:
try:
printf("Poll detected")
rgpd_popup(driver)
#rgpd_popup(driver)
do_poll()
printf("Poll succeeded")
except Exception as e:
@ -384,12 +383,12 @@ def try_play(nom="inconnu"):
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
printf("fidélité")
rgpd_popup(driver)
#rgpd_popup(driver)
fidelity()
else:
printf(f"rien à faire sur la page {nom}")
rgpd_popup(driver)
# rgpd_popup(driver)
custom_sleep(uniform(3, 5))
@ -468,13 +467,13 @@ def login(ldriver):
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
else:
log_error(e)
custom_sleep(20) # TODO : remplacer par un wait_element
log_error(e, ldriver)
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-rewards"]', 20, ldriver)
if ("account.microsoft.com" in ldriver.current_url) :
ldriver.get("https://bing.com")
custom_sleep(5)
ldriver.refresh()
rgpd_popup(ldriver)
rgpd_popup(ldriver) # Ultra important
ldriver.get("https://www.bing.com/rewardsapp/flyout")
if not('>Tableau de bord' in ldriver.page_source):
try :
@ -847,7 +846,7 @@ def daily_routine(custom = False):
def dev():
pass
log_error("test")
def CustomStart(Credentials):
@ -930,6 +929,9 @@ elif UNBAN:
elif POINTS_FILE != "":
save_points_from_file(POINTS_FILE)
else:
if UPDATE_VERSION != "None":
if DISCORD_ENABLED_ERROR:
webhookFailure.send(f"Updated to {UPDATE_VERSION}")
for cred in Credentials:
_mail = cred[0]
_password = cred[1]

View File

@ -10,9 +10,16 @@ parser.add_argument(
help="Choose a file",
type=argparse.FileType('r')
)
parser.add_argument(
"-m",
"--manual",
help="add point manually do database",
dest="manual",
action="store_true"
)
args = parser.parse_args()
MANUAL = args.manual
config_path = "./user_data/config.cfg"
config = configparser.ConfigParser()
@ -47,7 +54,7 @@ def ban_account(name: str, pts = 0):
def update_pts(name: str, pts = 0):
pass
if not MANUAL :
print("ajouter un compte : 1\nban un compte : 2")
i = input()
if i == "1":
@ -70,3 +77,16 @@ elif i == '2':
mydb.commit()
mycursor.close()
mydb.close()
else :
import modules.db as datab
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/MsRewards/user_data/config.cfg"
print(config_path)
config = configparser.ConfigParser()
config.read(config_path)
sql_usr = config["SQL"]["usr"]
sql_pwd = config["SQL"]["pwd"]
sql_host = config["SQL"]["host"]
sql_database = config["SQL"]["database"]
account_name = input("compte ? ")
points = int(input("points ? "))
datab.add_to_database(account_name, points, sql_host, sql_usr, sql_pwd, sql_database)

View File

@ -154,31 +154,32 @@ def proxy() :
edit_config_txt("port",port)
def check_update():
def check_update(args):
try :
latest = requests.get("https://api.github.com/repos/piair338/MsRewards/releases").json()[0]["tag_name"]
latest = parse_version(latest)
except Exception as e :
print(e)
return ()
return (args)
f = open("./version", 'r')
txt = f.readlines()[0].replace("\n","")
f.close()
cur = parse_version(txt)
if not (cur < latest) :
print("Already up to date.")
return(args)
else :
print(f"updating to {latest}")
os.system("git reset --hard")
os.system("git pull")
os.system("python3 -m pip install -r requirements.txt > update.result")
print(f"updated to {latest}")
return(args + f" --version {latest}")
LogPath = config["PATH"]["logpath"]
if LogPath == "/your/path/to/loginandpass.csv" :
setup()
else :
args = " ".join(sys.argv[1::])
check_update()
args = check_update(args)
os.system("python3 V5.py " + args)

View File

@ -81,6 +81,12 @@ parser.add_argument(
default="None"
)
parser.add_argument(
"--updated",
help="display a message on discord to tell that the bot have been updated",
dest="update_version",
default="None"
)
args = parser.parse_args()
CUSTOM_START = args.override
@ -93,7 +99,7 @@ if CUSTOM_START :
VNC_ENABLED = args.vnc != "None"
VNC_PORT = args.vnc
POINTS_FILE = args.points_file
UPDATE_VERSION = args.update_version
# global variables used later in the code
LINUX_HOST = platform == "linux" # if the computer running this program is Linux, it allow more things
START_TIME = time()
@ -125,6 +131,10 @@ DISCORD_SUCCESS_LINK = config["DISCORD"]["successlink"]
DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"]
DISCORD_ENABLED_ERROR = config["DISCORD"]["DiscordErrorEnabled"] == "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:
webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter())

View File

@ -31,5 +31,5 @@ usr = root
pwd = password
[OTHER]
avatar = https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp
ipv6 = False

View File

@ -1 +1 @@
v5.2.5
v5.4.0