Compare commits

..

3 Commits

Author SHA1 Message Date
f566b2eeda Potentially fix no-discord 2024-04-10 12:15:14 +02:00
52e88f81b9 More checks on TFA 2024-04-10 12:14:41 +02:00
1a8137783c Even faster cached build 2024-04-10 11:43:54 +02:00
9 changed files with 29 additions and 1474 deletions

View File

@ -25,6 +25,9 @@ RUN curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyri
RUN apt update \
&& apt install -y redis grafana
# Configure Grafana
RUN grafana-cli plugins install frser-sqlite-datasource
COPY requirements.txt /app/requirements.txt
RUN python3 -m pip install -r requirements.txt

17
V6.py
View File

@ -391,17 +391,22 @@ def login_part_1():
)
# 2FA
try:
wait_until_visible(By.ID, "idTxtBx_SAOTCC_OTC", browser=driver, timeout=5)
if not wait_until_visible(By.ID, "idTxtBx_SAOTCC_OTC", browser=driver, timeout=5, raise_error=False):
custom_sleep(2)
return
tfa = config.UserCredentials.get_tfa()
if tfa is None:
error("2FA needed but no code available for this account, sending error")
raise ValueError("2FA needed but no code available for this account")
else:
a2f_code = tfa.now()
a2f_code = config.UserCredentials.get_tfa().now()
info(f"Need 2FA, I have code: {a2f_code}")
send_wait_and_confirm(
driver.find_element(By.ID, "idTxtBx_SAOTCC_OTC"),
a2f_code
)
except NoSuchElementException:
custom_sleep(2)
pass
except Exception as err:
log_error(err)
@ -704,7 +709,7 @@ def json_start(json_entry, cred: UserCredentials):
config.WebDriver.switch_to_driver("PC")
driver = config.WebDriver.driver
try:
if str(account_id) in json_entry["unban"]:
if "unban" in json_entry and str(account_id) in json_entry["unban"]:
login_part_1()
info("\nGO TO example.com TO PROCEED or wait 1200 secs.")
for _ in range(1200):

View File

@ -59,7 +59,6 @@ sqlite3 /app/MsRewards-Reborn/MsRewards.db "CREATE TABLE comptes (id INTEGER PRI
printf "\nconfigurating grafana\n"
cp /app/MsRewards-Reborn/config/grafana.ini /etc/grafana/
grafana-cli plugins install frser-sqlite-datasource
printf "setting up default dashboard"
cp /app/MsRewards-Reborn/config/Stats-dashbord.json /usr/share/grafana/public/dashboards/home.json

File diff suppressed because it is too large Load Diff

View File

@ -50,9 +50,14 @@ class Config:
"""
self.discord = DiscordConfig()
self.discord.avatar_url = settings["avatarlink"]
self.discord.wh_link = discord[config[args.config]["discord"]]["errorsL"]
if self.discord.wh_link != "":
if (
"discord" in config[args.config]
and config[args.config]["discord"] in discord
and "errorsL" in discord[config[args.config]["discord"]]
and discord[config[args.config]["discord"]]["errorsL"] != ""
):
self.discord.wh_link = discord[config[args.config]["discord"]]["errorsL"]
self.discord.wh = Webhook.from_url(self.discord.wh_link, adapter=RequestsWebhookAdapter())
else:
self.discord.wh = FakeWebHook()

View File

@ -9,6 +9,6 @@ class DiscordConfig:
class FakeWebHook:
def send(self, *args):
debug(f"Used a webhook call without webhook url with {args}")
def send(self, *args, **kwargs):
debug(f"Used a webhook call without webhook url with {args} {kwargs}")

View File

@ -30,7 +30,8 @@ class UserCredentials:
def get_tfa(self):
if not self.tfa_enable():
warning("Warning: TFA is not enabled. Calling get_tfa is an expected behaviour.")
warning("Warning: TFA is not enabled. Can't get a TFA code.")
return None
return TOTP(self.data[self.current]["2fa"])
def next_account(self):

View File

@ -71,11 +71,12 @@ def send_wait_and_confirm(element, keys: str) -> None:
# Wait for the presence of the element identifier or [timeout]s
def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, browser=None) -> bool:
def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, browser=None, raise_error=True) -> bool:
try:
WebDriverWait(browser, timeout).until(
expected_conditions.visibility_of_element_located((search_by, identifier)), "element not found")
return True
except TimeoutException as e:
error(f"element {identifier} not found after {timeout}s")
if raise_error:
error(f"element {identifier} not found after {timeout}s")
return False

View File

@ -1 +1 @@
v6.8.44
v6.8.45