Answer the question
In order to leave comments, you need to log in
The bot is receiving messages, but the handler is not working, what should I do?
Hello! I had a problem, I'm writing a bot on aiogram, and so. The logs say that the message is accepted, but the handler does not work.
I am using the following libraries:
# aiogram 2.14.3
# pip 21.2.2
# aiogram-forms 0.1.1
# aiohttp 3.7.4.post0
# aioschedule 0.5.2
# async-timeout 3.0.1
# asyncio 3.4.3
# main.py
# from handlers import *
from aiogram import executor
from loader import *
from utils.notifier.notify import *
@dp.message_handler(commands=['start'])
async def start_command(message):
await message.answer("Hello")
async def on_startup(dispatcher: Dispatcher) -> None:
asyncio.create_task(scheduler())
async def on_shutdown(dispatcher: Dispatcher):
await dispatcher.storage.close()
await dispatcher.storage.wait_closed()
if __name__ == "__main__":
executor.start_polling(dp, skip_updates=True, on_shutdown=on_shutdown, on_startup=on_startup)
#loader.py
from aiogram import Bot, Dispatcher
from aiogram.contrib.fsm_storage.files import JSONStorage
from aiogram.contrib.middlewares.logging import LoggingMiddleware
from pathlib import Path
from data.config import BOT_TOKEN
import logging
logging.basicConfig(level=logging.INFO)
bot = Bot(token=BOT_TOKEN)
storage = JSONStorage(Path('states.json'))
dp = Dispatcher(bot, storage=storage)
dp.middleware.setup(LoggingMiddleware())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question