-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
57 lines (44 loc) · 1.76 KB
/
main.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from threading import Thread
from Bot import Bot
from DATA import bot
# @bot.message_handler(commands=['start'])
# def start(message):
# keyboard = fill_keyboard(options)
# rsp = "Welcome to SE Bot!"
# bot.send_message(message.chat.id, rsp, reply_markup=keyboard)
# def check_commands_boolean(message):
# global currentState
# for option in options:
# if option.optionName == message.text:
# currentState = option
# return True
# def next_handler(pm):
# print("next_handler:", pm)
# msg_text = pm.text
# rsp = currentState.runIt(msg_text)
# bot.send_message(pm.chat.id, rsp)
# if currentState.setup.get('rerun', ''):
# bot.register_next_step_handler(pm, next_handler) # Next message will call the name_handler function
# @bot.message_handler(func=check_commands_boolean)
# def runIt(message):
# sent_msg = bot.send_message(message.chat.id, currentState.setup.get('message', ''))
# keyboard = None
# print("currentState.options1:", currentState.options)
# if currentState.options:
# print("currentState.options:", currentState.options)
# keyboard = fill_keyboard(options)
#
# if currentState.setup.get('input'):
# bot.register_next_step_handler(sent_msg, next_handler) # Next message will call the name_handler function
# else:
# rsp = currentState.runIt()
# bot.send_message(message.chat.id, rsp, reply_markup=keyboard)
connectedClients = {}
@bot.message_handler()
def manager(message): # if none of above handlers run
print('[RECEIVED] request')
_bot = connectedClients.get(message.chat.id, Bot(message))
connectedClients[message.chat.id] = _bot
_bot.message = message
Thread(target=_bot.serve_it).start()
bot.polling()