-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelegram_bot.py
29 lines (19 loc) · 1.01 KB
/
telegram_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import logging
from telegram.ext import Updater, CommandHandler
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
TOKEN = '' # your token here
updater = Updater(token=TOKEN, use_context=True)
dispatcher = updater.dispatcher
def start(update, context):
context.bot.send_sticker(chat_id=update.effective_chat.id, sticker='CAACAgIAAxkBAAPqX2UNj7lpxN5zkwFDXvZy318bHxoAAlgEAALO2OgLbPcZZLyyHAYbBA')
context.bot.send_message(chat_id=update.effective_chat.id, text="I'm a bot, please talk to me :)")
logging.info(f'Got /start in chat_id {update.effective_chat.id}')
def echo(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.text)
from telegram.ext import MessageHandler, Filters
echo_handler = MessageHandler(Filters.sticker & (~Filters.command), echo)
dispatcher.add_handler(echo_handler)
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
updater.start_polling()