mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Fix some bugs
This commit is contained in:
parent
602056f783
commit
2b6fa5e74e
4 changed files with 6 additions and 4 deletions
|
@ -6,7 +6,7 @@ from .generic import GenericBot
|
||||||
from ..commands import NullCommand
|
from ..commands import NullCommand
|
||||||
from ..utils import asyncify, Call, Command
|
from ..utils import asyncify, Call, Command
|
||||||
from ..error import UnregisteredError, InvalidConfigError
|
from ..error import UnregisteredError, InvalidConfigError
|
||||||
from ..network import Message, RoyalnetConfig
|
from ..network import Message, RoyalnetConfig, Reply
|
||||||
from ..database import DatabaseConfig
|
from ..database import DatabaseConfig
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
@ -55,7 +55,7 @@ class TelegramBot(GenericBot):
|
||||||
async def net_request(call, message: Message, destination: str):
|
async def net_request(call, message: Message, destination: str):
|
||||||
if self.network is None:
|
if self.network is None:
|
||||||
raise InvalidConfigError("Royalnet is not enabled on this bot")
|
raise InvalidConfigError("Royalnet is not enabled on this bot")
|
||||||
response: Message = await self.network.request(message, destination)
|
response: Reply = await self.network.request(message, destination)
|
||||||
response.raise_on_error()
|
response.raise_on_error()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ class KvCommand(Command):
|
||||||
active = await asyncify(call.session.query(call.alchemy.ActiveKvGroup).filter_by(royal=author).one_or_none)
|
active = await asyncify(call.session.query(call.alchemy.ActiveKvGroup).filter_by(royal=author).one_or_none)
|
||||||
if active is None:
|
if active is None:
|
||||||
await call.reply("⚠️ Devi prima attivare un gruppo con il comando [c]kvactive[/c]!")
|
await call.reply("⚠️ Devi prima attivare un gruppo con il comando [c]kvactive[/c]!")
|
||||||
|
return
|
||||||
keyvalue = await asyncify(call.session.query(call.alchemy.Keyvalue).filter_by(group=active.group, key=key).one_or_none)
|
keyvalue = await asyncify(call.session.query(call.alchemy.Keyvalue).filter_by(group=active.group, key=key).one_or_none)
|
||||||
if value is None:
|
if value is None:
|
||||||
# Get
|
# Get
|
||||||
|
|
|
@ -47,7 +47,7 @@ class SyncCommand(Command):
|
||||||
telegram.first_name = user.first_name
|
telegram.first_name = user.first_name
|
||||||
telegram.last_name = user.last_name
|
telegram.last_name = user.last_name
|
||||||
telegram.username = user.username
|
telegram.username = user.username
|
||||||
await call.reply(f"✅ Dati di {str(telegram)} aggiornati.")
|
await call.reply(f"✅ Connessione aggiornata: {str(royal)} ⬌ {str(telegram)}")
|
||||||
# Commit the session
|
# Commit the session
|
||||||
await asyncify(call.session.commit)
|
await asyncify(call.session.commit)
|
||||||
|
|
||||||
|
@ -76,6 +76,6 @@ class SyncCommand(Command):
|
||||||
discord.username = user.name
|
discord.username = user.name
|
||||||
discord.discriminator = user.discriminator
|
discord.discriminator = user.discriminator
|
||||||
discord.avatar_hash = user.avatar
|
discord.avatar_hash = user.avatar
|
||||||
await call.reply(f"✅ Dati di {str(discord)} aggiornati.")
|
await call.reply(f"✅ Connessione aggiornata: {str(royal)} ⬌ {str(discord)}")
|
||||||
# Commit the session
|
# Commit the session
|
||||||
await asyncify(call.session.commit)
|
await asyncify(call.session.commit)
|
||||||
|
|
|
@ -35,6 +35,7 @@ tg_bot = TelegramBot(telegram_config=TelegramConfig(os.environ["TG_AK"]),
|
||||||
database_config=DatabaseConfig(os.environ["DB_PATH"], Royal, Telegram, "tg_id"),
|
database_config=DatabaseConfig(os.environ["DB_PATH"], Royal, Telegram, "tg_id"),
|
||||||
commands=commands,
|
commands=commands,
|
||||||
error_command=ErrorHandlerCommand)
|
error_command=ErrorHandlerCommand)
|
||||||
|
print(tg_bot.botfather_command_string)
|
||||||
loop.run_until_complete(master.start())
|
loop.run_until_complete(master.start())
|
||||||
loop.create_task(tg_bot.run())
|
loop.create_task(tg_bot.run())
|
||||||
loop.create_task(ds_bot.run())
|
loop.create_task(ds_bot.run())
|
||||||
|
|
Loading…
Reference in a new issue