Merge pull request #112 from fishyboteso/bugfix/active-not-working

This commit is contained in:
Adam Saudagar 2022-03-18 10:37:35 +05:30 committed by GitHub
commit a6d7a2ce27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -19,6 +19,7 @@ class active:
@staticmethod @staticmethod
def start(): def start():
web.ping()
active._scheduler.enter_recurring(60, 1, web.ping) active._scheduler.enter_recurring(60, 1, web.ping)
logging.debug("active scheduler started") logging.debug("active scheduler started")

View File

@ -126,7 +126,8 @@ def get_session(lazy=True):
# if not, create new id then try creating session again # if not, create new id then try creating session again
else: else:
uid = register_user() uid = register_user()
logging.debug("New User, generated new uid") config.set("uid", uid, True)
logging.debug(f"New User, generated new uid: {uid}")
if uid: if uid:
_session_id, online = _create_new_session(uid) _session_id, online = _create_new_session(uid)
else: else:
@ -137,8 +138,8 @@ def get_session(lazy=True):
logging.error("user not found, generating new uid.. contact dev if you don't want to loose data") logging.error("user not found, generating new uid.. contact dev if you don't want to loose data")
new_uid = register_user() new_uid = register_user()
_session_id, online = _create_new_session(new_uid) _session_id, online = _create_new_session(new_uid)
config.set("uid", new_uid) config.set("uid", new_uid, True)
config.set("old_uid", uid) config.set("old_uid", uid, True)
return _session_id return _session_id
@ -153,6 +154,7 @@ def _create_new_session(uid):
return response.json()["session_id"], True return response.json()["session_id"], True
@fallback(False) @fallback(False)
def has_beta(): def has_beta():
body = {"uid": config.get("uid"), "apiversion": apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
@ -168,4 +170,5 @@ def has_beta():
@fallback(None) @fallback(None)
def ping(): def ping():
body = {"uid": config.get("uid"), "apiversion": apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
requests.post(urls.ping, params=body) response = requests.post(urls.ping, params=body)
logging.debug(f"ping response: {response.json()}")