Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
if command not in ["weather", "dice"]:
send_message("Для получения информации о существующих командах введите /help")
After you describe the reactions to all the necessary commands, create a handler with a regular expression that will catch all messages starting with "/" and that will send your message.
Create a handler
@dp.message_handler() # Он принимает все запросы без фильтров
if message.text == 'тут твой текст':
pass # ответ
else:
send_message("Для получения информации о существующих командах введите /help")
Write your own filter:
from aiogram import types
from aiogram.dispatcher.filters import Filter, Command
class CommandNotInListFilter(Filter):
def __init__(self, commands: Command):
self.commands = commands
def check(self, message: types.Message) -> bool:
if not message.text.startswith('/'):
return False
return message.text[1:] in self.commands.commands
@dp.message_handler(
CommandNotInListFilter(Command(['start', 'help']))
)
async def handle_unknown_commands(message: types.Message):
await message.reply("Данной команды не существует!")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question