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

Generate botfather commands

This commit is contained in:
Steffo 2019-04-07 23:32:33 +02:00
parent af3dcb2f7f
commit a01402d383
14 changed files with 21 additions and 12 deletions

View file

@ -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)
loop.create_task(master.run())
loop.create_task(tg_bot.run())
print("Commands enabled:")
print(tg_bot.generate_botfather_command_string())
print("Starting loop...")
loop.run_forever()

View file

@ -136,5 +136,12 @@ class TelegramBot:
except Exception as 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):
pass

View file

@ -5,7 +5,7 @@ from telegram import Update, User
class CiaoruoziCommand(Command):
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 = ""
async def telegram(self, call: Call):

View file

@ -4,7 +4,7 @@ from ..utils import Command, CommandArgs, Call
class ColorCommand(Command):
command_name = "color"
command_title = "Invia un colore in chat...?"
command_description = "Invia un colore in chat...?"
command_syntax = ""
async def common(self, call: Call):

View file

@ -5,7 +5,7 @@ from ..database.tables import Royal, Telegram
class DebugAuthorCommand(Command):
command_name = "debug_author"
command_title = "Ottieni informazioni sull'autore di questa chiamata."
command_description = "Ottieni informazioni sull'autore di questa chiamata."
command_syntax = ""
require_alchemy_tables = {Royal, Telegram}

View file

@ -5,7 +5,7 @@ from ..database.tables import Royal, Alias
class DebugCreateCommand(Command):
command_name = "debug_create"
command_title = "Crea un nuovo account Royalnet"
command_description = "Crea un nuovo account Royalnet"
command_syntax = "(newusername)"
require_alchemy_tables = {Royal, Alias}

View file

@ -13,7 +13,7 @@ from ..utils import asyncify
class DiarioCommand(Command):
command_name = "diario"
command_title = "Aggiungi una citazione al Diario."
command_description = "Aggiungi una citazione al Diario."
command_syntax = "[!] \"(testo)\" --[autore], [contesto]"
require_alchemy_tables = {Royal, Diario, Alias}

View file

@ -6,7 +6,7 @@ from ..utils import Command, CommandArgs, Call, InvalidInputError, UnsupportedEr
class ErrorHandlerCommand(Command):
command_name = "error_handler"
command_title = "Gestisce gli errori causati dagli altri comandi."
command_description = "Gestisce gli errori causati dagli altri comandi."
command_syntax = ""
async def common(self, call: Call):

View file

@ -4,7 +4,7 @@ from ..utils import Command, CommandArgs, Call
class NullCommand(Command):
command_name = "null"
command_title = "Non fa nulla."
command_description = "Non fa nulla."
command_syntax = ""
async def common(self, call: Call):

View file

@ -4,7 +4,7 @@ from ..utils import Command, CommandArgs, Call
class PingCommand(Command):
command_name = "ping"
command_title = "Ping pong!"
command_description = "Ping pong!"
command_syntax = ""
async def common(self, call: Call):

View file

@ -8,7 +8,7 @@ SHIP_RESULT = "💕 {one} + {two} = [b]{result}[/b]"
class ShipCommand(Command):
command_name = "ship"
command_title = "Crea una ship tra due cose."
command_description = "Crea una ship tra due cose."
command_syntax = "(uno) (due)"
async def common(self, call: Call):

View file

@ -54,7 +54,7 @@ SMECDS = "🤔 Secondo me, è colpa {ds}."
class SmecdsCommand(Command):
command_name = "smecds"
command_title = "Secondo me, è colpa dello stagista..."
command_description = "Secondo me, è colpa dello stagista..."
command_syntax = ""
async def common(self, call: Call):

View file

@ -7,7 +7,7 @@ from ..database.tables import Royal, Telegram
class SyncCommand(Command):
command_name = "sync"
command_title = "Connetti il tuo account attuale a Royalnet!"
command_description = "Connetti il tuo account attuale a Royalnet!"
command_syntax = "(royalnetusername)"
require_alchemy_tables = {Royal, Telegram}

View file

@ -40,7 +40,7 @@ class Command:
"""A generic command, called from any source."""
command_name: str = NotImplemented
command_title: str = NotImplemented
command_description: str = NotImplemented
command_syntax: str = NotImplemented
require_alchemy_tables: typing.Set = set()