2015-07-03 00:38:11 +03:00
|
|
|
# This is a simple echo bot using the decorator mechanism.
|
|
|
|
# It echoes any incoming text messages.
|
|
|
|
|
2018-04-28 13:50:59 +03:00
|
|
|
import telebot
|
2015-07-03 00:38:11 +03:00
|
|
|
|
|
|
|
API_TOKEN = '<api_token>'
|
|
|
|
|
2018-04-28 13:50:59 +03:00
|
|
|
bot = telebot.TeleBot(API_TOKEN)
|
2015-07-03 00:38:11 +03:00
|
|
|
|
|
|
|
# Handle '/start' and '/help'
|
2015-07-03 10:04:11 +03:00
|
|
|
@bot.message_handler(commands=['help', 'start'])
|
2015-07-03 00:38:11 +03:00
|
|
|
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!\
|
|
|
|
""")
|
|
|
|
|
2015-07-03 00:47:05 +03:00
|
|
|
|
2015-07-03 00:38:11 +03:00
|
|
|
# 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()
|