mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Rename interface_alchemy to the simpler alchemy
This commit is contained in:
parent
59baf31dfe
commit
f7dec4d8cf
4 changed files with 11 additions and 12 deletions
|
@ -45,7 +45,7 @@ class TelegramBot:
|
|||
class TelegramCall(Call):
|
||||
interface_name = "telegram"
|
||||
interface_obj = self
|
||||
interface_alchemy = self.alchemy
|
||||
alchemy = self.alchemy
|
||||
|
||||
async def reply(call, text: str):
|
||||
await asyncify(call.channel.send_message, text, parse_mode="HTML")
|
||||
|
|
|
@ -10,7 +10,7 @@ class DebugCreateCommand(Command):
|
|||
require_alchemy_tables = {Royal}
|
||||
|
||||
async def common(self, call: Call, args: CommandArgs):
|
||||
royal = call.interface_alchemy.Royal(username=args[0], role="Member")
|
||||
royal = call.alchemy.Royal(username=args[0], role="Member")
|
||||
call.session.add(royal)
|
||||
call.session.commit()
|
||||
await call.reply(f"✅ Utente <code>{royal}</code> creato!")
|
||||
|
|
|
@ -21,19 +21,19 @@ class SyncCommand(Command):
|
|||
if user is None:
|
||||
raise ValueError("Trying to sync a None user.")
|
||||
# Find the Royal
|
||||
royal = await asyncify(call.session.query(call.interface_alchemy.Royal).filter_by(username=args[0]).one_or_none)
|
||||
royal = await asyncify(call.session.query(call.alchemy.Royal).filter_by(username=args[0]).one_or_none)
|
||||
if royal is None:
|
||||
await call.reply("⚠️ Non esiste alcun account Royalnet con quel nome.")
|
||||
# Find if the user is already synced
|
||||
telegram = await asyncify(call.session.query(call.interface_alchemy.Telegram).filter_by(tg_id=user.id).one_or_none)
|
||||
telegram = await asyncify(call.session.query(call.alchemy.Telegram).filter_by(tg_id=user.id).one_or_none)
|
||||
if telegram is None:
|
||||
# Create a Telegram to connect to the Royal
|
||||
# Avatar is WIP
|
||||
telegram = call.interface_alchemy.Telegram(royal=royal,
|
||||
tg_id=user.id,
|
||||
tg_first_name=user.first_name,
|
||||
tg_last_name=user.last_name,
|
||||
tg_username=user.username)
|
||||
telegram = call.alchemy.Telegram(royal=royal,
|
||||
tg_id=user.id,
|
||||
tg_first_name=user.first_name,
|
||||
tg_last_name=user.last_name,
|
||||
tg_username=user.username)
|
||||
call.session.add(telegram)
|
||||
await call.reply(f"✅ Connessione completata: <code>{str(royal)}</code> ⬌ <code>{str(telegram)}</code>")
|
||||
else:
|
||||
|
@ -45,4 +45,3 @@ class SyncCommand(Command):
|
|||
await call.reply(f"✅ Dati di <code>{str(telegram)}</code> aggiornati.")
|
||||
# Commit the session
|
||||
await asyncify(call.session.commit())
|
||||
# Notify the user
|
||||
|
|
|
@ -15,7 +15,7 @@ class Call:
|
|||
# These parameters / methods should be overridden
|
||||
interface_name = NotImplemented
|
||||
interface_obj = NotImplemented
|
||||
interface_alchemy: "Alchemy" = NotImplemented
|
||||
alchemy: "Alchemy" = NotImplemented
|
||||
|
||||
async def reply(self, text: str):
|
||||
"""Send a text message to the channel the call was made."""
|
||||
|
@ -37,7 +37,7 @@ class Call:
|
|||
async def session_init(self):
|
||||
if not self.command.require_alchemy_tables:
|
||||
return
|
||||
self.session = await loop.run_in_executor(None, self.interface_alchemy.Session)
|
||||
self.session = await loop.run_in_executor(None, self.alchemy.Session)
|
||||
|
||||
async def session_end(self):
|
||||
if not self.session:
|
||||
|
|
Loading…
Reference in a new issue