mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Generate botfather commands
This commit is contained in:
parent
af3dcb2f7f
commit
a01402d383
14 changed files with 21 additions and 12 deletions
|
@ -17,5 +17,7 @@ master = RoyalnetServer("localhost", 1234, "sas")
|
||||||
tg_bot = TelegramBot(os.environ["TG_AK"], "localhost:1234", "sas", commands, os.environ["DB_PATH"], Royal, Telegram, "tg_id", error_command=ErrorHandlerCommand)
|
tg_bot = TelegramBot(os.environ["TG_AK"], "localhost:1234", "sas", commands, os.environ["DB_PATH"], Royal, Telegram, "tg_id", error_command=ErrorHandlerCommand)
|
||||||
loop.create_task(master.run())
|
loop.create_task(master.run())
|
||||||
loop.create_task(tg_bot.run())
|
loop.create_task(tg_bot.run())
|
||||||
|
print("Commands enabled:")
|
||||||
|
print(tg_bot.generate_botfather_command_string())
|
||||||
print("Starting loop...")
|
print("Starting loop...")
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
|
|
|
@ -136,5 +136,12 @@ class TelegramBot:
|
||||||
except Exception as exc2:
|
except Exception as exc2:
|
||||||
log.error(f"Exception in error handler command: {exc2}")
|
log.error(f"Exception in error handler command: {exc2}")
|
||||||
|
|
||||||
|
def generate_botfather_command_string(self):
|
||||||
|
string = ""
|
||||||
|
for command_key in self.commands:
|
||||||
|
command = self.commands[command_key]
|
||||||
|
string += f"{command.command_name} - {command.command_description}\n"
|
||||||
|
return string
|
||||||
|
|
||||||
async def handle_net_request(self, message: Message):
|
async def handle_net_request(self, message: Message):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -5,7 +5,7 @@ from telegram import Update, User
|
||||||
class CiaoruoziCommand(Command):
|
class CiaoruoziCommand(Command):
|
||||||
|
|
||||||
command_name = "ciaoruozi"
|
command_name = "ciaoruozi"
|
||||||
command_title = "Saluta Ruozi, anche se non è più in RYG."
|
command_description = "Saluta Ruozi, anche se non è più in RYG."
|
||||||
command_syntax = ""
|
command_syntax = ""
|
||||||
|
|
||||||
async def telegram(self, call: Call):
|
async def telegram(self, call: Call):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from ..utils import Command, CommandArgs, Call
|
||||||
class ColorCommand(Command):
|
class ColorCommand(Command):
|
||||||
|
|
||||||
command_name = "color"
|
command_name = "color"
|
||||||
command_title = "Invia un colore in chat...?"
|
command_description = "Invia un colore in chat...?"
|
||||||
command_syntax = ""
|
command_syntax = ""
|
||||||
|
|
||||||
async def common(self, call: Call):
|
async def common(self, call: Call):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from ..database.tables import Royal, Telegram
|
||||||
class DebugAuthorCommand(Command):
|
class DebugAuthorCommand(Command):
|
||||||
|
|
||||||
command_name = "debug_author"
|
command_name = "debug_author"
|
||||||
command_title = "Ottieni informazioni sull'autore di questa chiamata."
|
command_description = "Ottieni informazioni sull'autore di questa chiamata."
|
||||||
command_syntax = ""
|
command_syntax = ""
|
||||||
|
|
||||||
require_alchemy_tables = {Royal, Telegram}
|
require_alchemy_tables = {Royal, Telegram}
|
||||||
|
|
|
@ -5,7 +5,7 @@ from ..database.tables import Royal, Alias
|
||||||
class DebugCreateCommand(Command):
|
class DebugCreateCommand(Command):
|
||||||
|
|
||||||
command_name = "debug_create"
|
command_name = "debug_create"
|
||||||
command_title = "Crea un nuovo account Royalnet"
|
command_description = "Crea un nuovo account Royalnet"
|
||||||
command_syntax = "(newusername)"
|
command_syntax = "(newusername)"
|
||||||
|
|
||||||
require_alchemy_tables = {Royal, Alias}
|
require_alchemy_tables = {Royal, Alias}
|
||||||
|
|
|
@ -13,7 +13,7 @@ from ..utils import asyncify
|
||||||
class DiarioCommand(Command):
|
class DiarioCommand(Command):
|
||||||
|
|
||||||
command_name = "diario"
|
command_name = "diario"
|
||||||
command_title = "Aggiungi una citazione al Diario."
|
command_description = "Aggiungi una citazione al Diario."
|
||||||
command_syntax = "[!] \"(testo)\" --[autore], [contesto]"
|
command_syntax = "[!] \"(testo)\" --[autore], [contesto]"
|
||||||
|
|
||||||
require_alchemy_tables = {Royal, Diario, Alias}
|
require_alchemy_tables = {Royal, Diario, Alias}
|
||||||
|
|
|
@ -6,7 +6,7 @@ from ..utils import Command, CommandArgs, Call, InvalidInputError, UnsupportedEr
|
||||||
class ErrorHandlerCommand(Command):
|
class ErrorHandlerCommand(Command):
|
||||||
|
|
||||||
command_name = "error_handler"
|
command_name = "error_handler"
|
||||||
command_title = "Gestisce gli errori causati dagli altri comandi."
|
command_description = "Gestisce gli errori causati dagli altri comandi."
|
||||||
command_syntax = ""
|
command_syntax = ""
|
||||||
|
|
||||||
async def common(self, call: Call):
|
async def common(self, call: Call):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from ..utils import Command, CommandArgs, Call
|
||||||
class NullCommand(Command):
|
class NullCommand(Command):
|
||||||
|
|
||||||
command_name = "null"
|
command_name = "null"
|
||||||
command_title = "Non fa nulla."
|
command_description = "Non fa nulla."
|
||||||
command_syntax = ""
|
command_syntax = ""
|
||||||
|
|
||||||
async def common(self, call: Call):
|
async def common(self, call: Call):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from ..utils import Command, CommandArgs, Call
|
||||||
class PingCommand(Command):
|
class PingCommand(Command):
|
||||||
|
|
||||||
command_name = "ping"
|
command_name = "ping"
|
||||||
command_title = "Ping pong!"
|
command_description = "Ping pong!"
|
||||||
command_syntax = ""
|
command_syntax = ""
|
||||||
|
|
||||||
async def common(self, call: Call):
|
async def common(self, call: Call):
|
||||||
|
|
|
@ -8,7 +8,7 @@ SHIP_RESULT = "💕 {one} + {two} = [b]{result}[/b]"
|
||||||
class ShipCommand(Command):
|
class ShipCommand(Command):
|
||||||
|
|
||||||
command_name = "ship"
|
command_name = "ship"
|
||||||
command_title = "Crea una ship tra due cose."
|
command_description = "Crea una ship tra due cose."
|
||||||
command_syntax = "(uno) (due)"
|
command_syntax = "(uno) (due)"
|
||||||
|
|
||||||
async def common(self, call: Call):
|
async def common(self, call: Call):
|
||||||
|
|
|
@ -54,7 +54,7 @@ SMECDS = "🤔 Secondo me, è colpa {ds}."
|
||||||
class SmecdsCommand(Command):
|
class SmecdsCommand(Command):
|
||||||
|
|
||||||
command_name = "smecds"
|
command_name = "smecds"
|
||||||
command_title = "Secondo me, è colpa dello stagista..."
|
command_description = "Secondo me, è colpa dello stagista..."
|
||||||
command_syntax = ""
|
command_syntax = ""
|
||||||
|
|
||||||
async def common(self, call: Call):
|
async def common(self, call: Call):
|
||||||
|
|
|
@ -7,7 +7,7 @@ from ..database.tables import Royal, Telegram
|
||||||
class SyncCommand(Command):
|
class SyncCommand(Command):
|
||||||
|
|
||||||
command_name = "sync"
|
command_name = "sync"
|
||||||
command_title = "Connetti il tuo account attuale a Royalnet!"
|
command_description = "Connetti il tuo account attuale a Royalnet!"
|
||||||
command_syntax = "(royalnetusername)"
|
command_syntax = "(royalnetusername)"
|
||||||
|
|
||||||
require_alchemy_tables = {Royal, Telegram}
|
require_alchemy_tables = {Royal, Telegram}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Command:
|
||||||
"""A generic command, called from any source."""
|
"""A generic command, called from any source."""
|
||||||
|
|
||||||
command_name: str = NotImplemented
|
command_name: str = NotImplemented
|
||||||
command_title: str = NotImplemented
|
command_description: str = NotImplemented
|
||||||
command_syntax: str = NotImplemented
|
command_syntax: str = NotImplemented
|
||||||
|
|
||||||
require_alchemy_tables: typing.Set = set()
|
require_alchemy_tables: typing.Set = set()
|
||||||
|
|
Loading…
Reference in a new issue