-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot.py
More file actions
31 lines (20 loc) · 805 Bytes
/
bot.py
File metadata and controls
31 lines (20 loc) · 805 Bytes
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
30
31
import sys
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
def start(update, context):
update.message.reply_text('Hi!')
def help(update, context):
update.message.reply_text('Help!')
def echo(update, context):
update.message.reply_text(update.message.text)
def error(update, context):
print('Update "%s" caused error "%s"', update, context.error)
if __name__ == '__main__':
updater = Updater(sys.argv[1], use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(CommandHandler("help", help))
dispatcher.add_handler(MessageHandler(Filters.text, echo))
dispatcher.add_error_handler(error)
updater.start_polling()
print("Hello world")
updater.idle()