aiogram
aiogram copied to clipboard
/start doesn't work
Checklist
- [X] I am sure the error is coming from aiogram code
- [X] I have searched in the issue tracker for similar bug reports, including closed ones
Operating system
Ubuntu 22.4
Python version
3.8
aiogram version
2.21
Expected behavior
Bots responds
Current behavior
/start doesn't work for the bot I made with aiogram. But for all other users it works perfectly. What could be a problem?
Steps to reproduce
- Open bot @WishShareBot
- Type /start
- It works (but not for me @sevocrear
Code example
No response
Logs
No logs from bot as it doesn't respond to my account
Additional information
No response
As I figured out, it doesn't get messages from second account. But if I turn my script off, getUpdate (https://api.telegram.org/bot'token'/getUpdates) get all the messages I send to the bot:
{"ok":true,"result":[{"update_id":967979408, "message":{"message_id":143,"from":{"id":489327708,"is_bot":false,"first_name":"Ilia","last_name":"Sevostianov","username":"sevocrear","language_code":"ru","is_premium":true},"chat":{"id":489327708,"first_name":"Ilia","last_name":"Sevostianov","username":"sevocrear","type":"private"},"date":1712478116,"text":"For"}}]}
Looks like a non-aiogram issue. Debug your application or send minimal reproducible example
Have some problem now. Bot can send messages, but not handling any commands
Have some problem now. Bot can send messages, but not handling any commands
@Petrprogs, still need minimal reproducible example
Have some problem now. Bot can send messages, but not handling any commands
@Petrprogs, still need minimal reproducible example
This was problem in my code:
import asyncio
from aiogram import Bot, Dispatcher, types, F
from aiogram.filters import Command
bot = Bot(token=TG_TOKEN)
dp = Dispatcher()
@dp.message(Command("start"))
async def send_welcome(msg):
await msg.reply("Hi there!")
async def main_loop():
while True:
print("Some infinty loop")
await asyncio.sleep(10)
asyncio.run(main_loop())
asyncio.run(dp.start_polling(bot)) # This won't run, because main_loop() has infinity while loop
To solve this a just moved dp.start_polling(bot) to main_loop() like this:
import asyncio
from aiogram import Bot, Dispatcher, types, F
from aiogram.filters import Command
bot = Bot(token=TG_TOKEN)
dp = Dispatcher()
@dp.message(Command("start"))
async def send_welcome(msg):
await msg.reply("Hi there!")
async def main_loop():
asyncio.create_task(dp.start_polling(bot))
while True:
print("Some infinty loop")
await asyncio.sleep(10)
asyncio.run(main_loop())
Sorry for my weird code :)