pyTelegramBotAPI/examples/asynchronous_telebot/update_listener.py

16 lines
412 B
Python
Raw Normal View History

2021-12-04 19:54:26 +03:00
from telebot.async_telebot import AsyncTeleBot
# Update listeners are functions that are called when any update is received.
bot = AsyncTeleBot(token='TOKEN')
async def update_listener(messages):
for message in messages:
if message.text == '/start':
await bot.send_message(message.chat.id, 'Hello!')
bot.set_update_listener(update_listener)
2021-12-12 13:07:30 +03:00
import asyncio
asyncio.run(bot.polling())