-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (20 loc) · 686 Bytes
/
main.py
File metadata and controls
29 lines (20 loc) · 686 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
import Constants
import Responses
import telegram.ext as te
print('Bot is running...')
updater = te.Updater(Constants.API_KEY, use_context=True)
dp = updater.dispatcher
dp.add_handler(te.CommandHandler('help', Responses.handle_help))
dp.add_handler(te.CommandHandler('namespace', Responses.handle_namespace))
dp.add_handler(te.MessageHandler(te.Filters.text, Responses.handle_msg))
dp.add_error_handler(Responses.error)
update_queue = updater.start_polling(timeout=10)
#updater.idle()
while True:
text = input()
# Gracefully stop the event handler
if text == 'stop':
update_queue.put('bot stopped.')
updater.stop()
break
print('Bot closed')