mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
![Waffle](/assets/img/avatar_default.png)
Rename telebot package to pytelegrambotapi becouse lib named telebot exists and it raising many errors Add methods: | register_for_reply_by_message_id, | register_next_step_handler_by_chat_id, | clear_reply_handlers, | clear_reply_handlers_by_message_id
25 lines
696 B
Python
25 lines
696 B
Python
# This is a simple echo bot using the decorator mechanism.
|
|
# It echoes any incoming text messages.
|
|
|
|
import pytelegrambotapi
|
|
|
|
API_TOKEN = '<api_token>'
|
|
|
|
bot = pytelegrambotapi.TeleBot(API_TOKEN)
|
|
|
|
# Handle '/start' and '/help'
|
|
@bot.message_handler(commands=['help', 'start'])
|
|
def send_welcome(message):
|
|
bot.reply_to(message, """\
|
|
Hi there, I am EchoBot.
|
|
I am here to echo your kind words back to you. Just say anything nice and I'll say the exact same thing to you!\
|
|
""")
|
|
|
|
|
|
# Handle all other messages with content_type 'text' (content_types defaults to ['text'])
|
|
@bot.message_handler(func=lambda message: True)
|
|
def echo_message(message):
|
|
bot.reply_to(message, message.text)
|
|
|
|
bot.polling()
|