My Python telegram bot (aiogram 2.25) is not responding to /start, /admin commands.
This is the structure of the files:
├── bot.py
├── config.py
└── handlers/
└── command.py
The bot responds to all commands except the ‘register hundler’ commands. On startup the bot shows “Handlers registered” from registerHandlers_comm, but does not respond to commands.
There are no errors, only ignoring
bot.py:
from aiogram.dispatcher.filters import Command, Text
import asyncio
import logging
from handlers.command import start, admin
from data.config import *
def registerHandlers_comm(dp: Dispatcher):
dp.register_message_handler(start, Command('start'))
dp.register_message_handler(admin, Command('admin'))
logging.info("Handlers registered")
async def main():
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
)
logger.info("Starting bot")
registerHandlers_comm(dp)
await asyncio.gather(
dp.start_polling()
)
if __name__ == "__main__":
asyncio.run(main())
config.py:
from aiogram import Bot, Dispatcher
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.contrib.middlewares.logging import LoggingMiddleware
BOT_TOKEN: str = ':'
adminID: int = 1111111
storage = MemoryStorage()
bot = Bot(BOT_TOKEN, parse_mode='HTML')
dp = Dispatcher(bot, storage=storage)
dp.middleware.setup(LoggingMiddleware())
command.py:
from aiogram import types
from colorama import Fore, init
import logging
init()
from data.config import bot, adminID
from core.selectData import _selectData
from keyboards import adm, Key
from decorators.login import login
async def start(message: types.Message):
logging.info(
f" {Fore.GREEN}User {message.from_user.username} ({message.from_user.id}) write: {'/start'}{Fore.RESET}")
await bot.send_message(message.from_user.id, '???? Hi', reply_markup=Key)
async def admin(message: types.Message):
logging.info(
f" {Fore.GREEN}User {message.from_user.username} ({message.from_user.id}) write: {'/admin'}{Fore.RESET}")
if message.from_user.id == adminID:
await bot.send_message(message.from_user.id, '???? Выберите действие', reply_markup=adm)
New contributor
YUMORIST is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.