1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 11:34:18 +00:00

🧹 Cleanup code

This commit is contained in:
Steffo 2021-04-19 19:39:01 +02:00
parent e75fcf6499
commit 2671fa7f79
Signed by: steffo
GPG key ID: 6965406171929D01
6 changed files with 25 additions and 18 deletions

View file

@ -3,13 +3,15 @@
""" """
from __future__ import annotations from __future__ import annotations
import typing as t
import functools import functools
import logging
import royalnet.engineer as engi
import royalnet_telethon
import sqlalchemy.orm as so import sqlalchemy.orm as so
import sqlalchemy.sql as ss import sqlalchemy.sql as ss
import royalnet.engineer as engi
import logging
import royalnet_telethon
import royalpack.database as db import royalpack.database as db
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -26,6 +28,7 @@ def use_ryglogin(allow_anonymous=False):
an error instead. an error instead.
:return: The decorator to use to decorate the function. :return: The decorator to use to decorate the function.
""" """
def decorator(f): def decorator(f):
@functools.wraps(f) @functools.wraps(f)
async def decorated(_session: so.Session, _imp: engi.PDAImplementation, _msg: engi.Message, **f_kwargs): async def decorated(_session: so.Session, _imp: engi.PDAImplementation, _msg: engi.Message, **f_kwargs):
@ -56,7 +59,9 @@ def use_ryglogin(allow_anonymous=False):
return return
return await f(_session=_session, _imp=_imp, _msg=_msg, **f_kwargs, _account=account, _user=user) return await f(_session=_session, _imp=_imp, _msg=_msg, **f_kwargs, _account=account, _user=user)
return decorated return decorated
return decorator return decorator

View file

@ -1,8 +1,8 @@
import royalnet.engineer as engi
import royalnet.engineer.conversation as c
import aiohttp
import logging
import io import io
import logging
import aiohttp
import royalnet.engineer as engi
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,5 +1,4 @@
import royalnet.engineer as engi import royalnet.engineer as engi
import royalnet.engineer.conversation as c
@engi.TeleportingConversation @engi.TeleportingConversation

View file

@ -1,7 +1,8 @@
import royalnet.engineer as engi
import aiohttp
import io import io
import aiohttp
import royalnet.engineer as engi
@engi.TeleportingConversation @engi.TeleportingConversation
async def dog_any(*, _msg: engi.Message, **__): async def dog_any(*, _msg: engi.Message, **__):

View file

@ -10,9 +10,9 @@ import logging
import arrow import arrow
import async_timeout import async_timeout
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# FIXME: Properly handle errors in this function! # FIXME: Properly handle errors in this function!
@ -22,6 +22,7 @@ async def login(*, _msg: engi.Message, _session: so.Session, _imp, **__):
""" """
Fai il login al tuo RYGaccount. Fai il login al tuo RYGaccount.
""" """
log.debug("Evaluating config...") log.debug("Evaluating config...")
config = cfg.lazy_config.evaluate() config = cfg.lazy_config.evaluate()
@ -140,10 +141,10 @@ async def prompt_login(channel: engi.Channel, verification_url: str, user_code:
log.debug("Asking user to login...") log.debug("Asking user to login...")
await channel.send_message( await channel.send_message(
text=f"🌍 Effettua il RYGlogin al seguente URL, poi premi Confirm:\n" text=f"🌍 Effettua il RYGlogin al seguente URL, poi premi Confirm:\n"
f"{verification_url}\n" f"{verification_url}\n"
f"\n" f"\n"
f"(Codice: {user_code})" f"(Codice: {user_code})"
) )

View file

@ -1,7 +1,8 @@
import royalnet.engineer as engi
import logging import logging
import re import re
import royalnet.engineer as engi
log = logging.getLogger(__name__) log = logging.getLogger(__name__)