|
|
@ -120,6 +120,7 @@ class Bot(telebot.TeleBot): |
|
|
|
self.db.users.replace_one({'user_id': user.user_id}, user.dict()) |
|
|
|
self.db.users.replace_one({'user_id': user.user_id}, user.dict()) |
|
|
|
|
|
|
|
|
|
|
|
def save_community(self, community: Community): |
|
|
|
def save_community(self, community: Community): |
|
|
|
|
|
|
|
print(community.dict()) |
|
|
|
self.db.communities.replace_one({'chat_id': community.chat_id}, community.dict()) |
|
|
|
self.db.communities.replace_one({'chat_id': community.chat_id}, community.dict()) |
|
|
|
|
|
|
|
|
|
|
|
def handle_commands(self, cmds: typing.List[str]): |
|
|
|
def handle_commands(self, cmds: typing.List[str]): |
|
|
@ -156,13 +157,14 @@ class Bot(telebot.TeleBot): |
|
|
|
args = query.data.strip()[len(name) + 1:] |
|
|
|
args = query.data.strip()[len(name) + 1:] |
|
|
|
try: |
|
|
|
try: |
|
|
|
return func(query, user, args.strip()) |
|
|
|
return func(query, user, args.strip()) |
|
|
|
|
|
|
|
except KeyboardInterrupt as e: |
|
|
|
|
|
|
|
raise e |
|
|
|
except Exception: |
|
|
|
except Exception: |
|
|
|
print(f'An exception occured: {traceback.format_exc()}') |
|
|
|
print(f'An exception occured: {traceback.format_exc()}') |
|
|
|
|
|
|
|
|
|
|
|
self.callback_query_handler( |
|
|
|
self.callback_query_handler( |
|
|
|
lambda query: query.data.strip().startswith(name + '_') or query.data.strip() == name)(func_wrapped) |
|
|
|
lambda query: query.data.strip().startswith(name + '_') or query.data.strip() == name)(func_wrapped) |
|
|
|
return func_wrapped |
|
|
|
return func_wrapped |
|
|
|
|
|
|
|
|
|
|
|
return wrapper |
|
|
|
return wrapper |
|
|
|
|
|
|
|
|
|
|
|
def inline_handler_(self, filter_func, **kwargs): |
|
|
|
def inline_handler_(self, filter_func, **kwargs): |
|
|
@ -201,6 +203,12 @@ class Bot(telebot.TeleBot): |
|
|
|
community.polled[user_id] = datetime.date.today() |
|
|
|
community.polled[user_id] = datetime.date.today() |
|
|
|
self.save_community(community) |
|
|
|
self.save_community(community) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def send_meeting_info_in_community(self, community: Community): |
|
|
|
|
|
|
|
for meeting in community.scheduled_meetings: |
|
|
|
|
|
|
|
person_1, person_2 = self.get_chat(meeting[0]), self.get_chat(meeting[1]) |
|
|
|
|
|
|
|
self.send_template(meeting[0], 'meeting_info', community=community, meeting=meeting, person=person_2) |
|
|
|
|
|
|
|
self.send_template(meeting[1], 'meeting_info', community=community, meeting=meeting, person=person_1) |
|
|
|
|
|
|
|
|
|
|
|
def register_next_step_handler(self, message, callback, *args, **kwargs): |
|
|
|
def register_next_step_handler(self, message, callback, *args, **kwargs): |
|
|
|
if isinstance(message, telebot.types.CallbackQuery): |
|
|
|
if isinstance(message, telebot.types.CallbackQuery): |
|
|
|
message = message.message |
|
|
|
message = message.message |
|
|
|