skip to Main Content

I specifically commented out all the code leaving only one initial handler for the start command
When I start the bot I see in the logs that the bot started correctly and there is no error, but at the same time in the chat the bot does not react to the start command.

import logging
from aiogram import Bot, Dispatcher, types
import openai
from config import OPEN_AI_KEY, BOT_TOKEN


BOT_TOKEN = BOT_TOKEN
OPEN_AI_KEY = OPEN_AI_KEY



bot = Bot(token=BOT_TOKEN)
dp = Dispatcher(bot)

openai.api_key = OPEN_AI_KEY

logging.basicConfig(level=logging.INFO)



dp.message_handler(commands=['start'])
async def start(message: types.Message):
    await message.reply('Привет! Для начала коротко опиши какой пост и для какого проекта вы бы хотели создать ')

here is the code

and below is the message I see in the logs when I run the bot. 


FO:aiogram:Bot: Instagram_Posts_Generate [@instagram_posts_generations_bot]
WARNING:aiogram:Updates were skipped successfully.
INFO:aiogram.dispatcher.dispatcher:Start polling.

I have tried everything I know and the bot token is specified exactly correctly and I have not made any mistakes in creating instances, as well as the virtual environment is created correctly and all the necessary dependencies are installed in it

2

Answers


  1. import os
    import logging
    from aiogram import Bot, Dispatcher, types
    import openai
    
    BOT_TOKEN = "BOT_TOKEN"
    OPEN_AI_KEY = "OPEN_AI_KEY"
    
    bot = Bot(token=BOT_TOKEN)
    dp = Dispatcher(bot)
    
    openai.api_key = OPEN_AI_KEY
    
    logging.basicConfig(level=logging.INFO)
    
    @dp.message_handler(commands=['start'])
    async def start(message: types.Message):
        await message.reply('Привет! Для начала коротко опиши какой пост и для какого проекта вы бы хотели создать ')
    
    if __name__ == '__main__':
        from aiogram import executor
        executor.start_polling(dp, skip_updates=True)
    

    Try this hope it works for you, replace the BOT_TOKEN AND OPEN_AI_KEY with yours

    Login or Signup to reply.
  2. You forgot "@" when use dp.message_handler Decorator. So, it will be enough

    replace

    dp.message_handler(commands=['start'])
    

    to

    @dp.message_handler(commands=['start'])
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search