|
import logging |
|
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters |
|
|
|
|
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
|
level=logging.INFO) |
|
|
|
|
|
TOKEN = '6516533220:AAEoq0ohv4xAraIw7lB7BZVHKyUg85wo3mI' |
|
|
|
|
|
updater = Updater(token=TOKEN, use_context=True) |
|
dispatcher = updater.dispatcher |
|
|
|
|
|
def start(update, context): |
|
context.bot.send_message(chat_id=update.effective_chat.id, text="Hello! I am your Telegram bot.") |
|
|
|
|
|
def echo(update, context): |
|
context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.text) |
|
|
|
|
|
start_handler = CommandHandler('start', start) |
|
echo_handler = MessageHandler(Filters.text & ~Filters.command, echo) |
|
|
|
dispatcher.add_handler(start_handler) |
|
dispatcher.add_handler(echo_handler) |
|
|
|
|
|
updater.start_polling() |
|
updater.idle() |
|
|