-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsender.py
More file actions
27 lines (22 loc) · 950 Bytes
/
Copy pathsender.py
File metadata and controls
27 lines (22 loc) · 950 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
admins = tuple()
def is_cancel(message: str):
return message == '/cancel'
def is_admin(chat_id: int):
return chat_id in admins
def cancel_end(bot, message):
bot.send_message(chat_id=message.chat.id, text=f'Current operation canceled.')
def chain_message(bot, message, answer_text: str, next_func):
res = is_admin(message.chat.id) and not is_cancel(message.text)
if is_cancel(message.text):
cancel_end(bot, message)
elif res:
bot.send_message(chat_id=message.chat.id, text=f'{answer_text}\nRun /cancel to cancel action.')
bot.register_next_step_handler(message, next_func)
return res
def chain_end(bot, message, answer_text: str):
res = is_admin(message.chat.id) and not is_cancel(message.text)
if is_cancel(message.text):
cancel_end(bot, message)
elif res:
bot.send_message(chat_id=message.chat.id, text=f'{answer_text}\nRun /update to see changes.')
return res