-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_bot_local.py
More file actions
43 lines (28 loc) · 915 Bytes
/
start_bot_local.py
File metadata and controls
43 lines (28 loc) · 915 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
32
33
34
35
36
37
38
39
40
41
42
43
"""
start_bot_local.py
Starts the bot process, after initialising and registering handlers.
"""
from telegram.ext import Updater, PicklePersistence
import logging
import os
# Local imports
from modules.handlers import handlers
from modules.generic_logic import error as error_handler
# Globals
BOT_TOKEN = "your_bot_token"
def initialise(bot_token, persistence_pickle):
persistence = PicklePersistence(filename=persistence_pickle)
up = Updater(token=bot_token, persistence=persistence, use_context=True)
dp = up.dispatcher
return up, dp
def add_handlers_to_dp(dp, handlers, error_handler):
for h in handlers:
dp.add_handler(handlers[h])
dp.add_error_handler(error_handler)
def start():
up, dp = initialise(BOT_TOKEN, "undercast.pickle")
add_handlers_to_dp(dp, handlers, error_handler)
up.start_polling()
up.idle()
if __name__ == "__main__":
start()