|
|
@ -53,8 +53,7 @@ class Bot(telebot.TeleBot): |
|
|
|
typing.Tuple[str, typing.Union[telebot.types.ReplyKeyboardMarkup, telebot.types.InlineKeyboardMarkup]]: |
|
|
|
typing.Tuple[str, typing.Union[telebot.types.ReplyKeyboardMarkup, telebot.types.InlineKeyboardMarkup]]: |
|
|
|
text: str = self.templates.render_template(template_name, user.locale, user=user, **kwargs) |
|
|
|
text: str = self.templates.render_template(template_name, user.locale, user=user, **kwargs) |
|
|
|
text, keyboard = self.templates.separate_text_and_keyboards(text) |
|
|
|
text, keyboard = self.templates.separate_text_and_keyboards(text) |
|
|
|
keyboard = utils.create_keyboard(keyboard) if keyboard is not None \ |
|
|
|
keyboard = utils.create_keyboard(keyboard) |
|
|
|
else self.main_keyboard.get(user.locale, self.main_keyboard.get('ru')) |
|
|
|
|
|
|
|
return text, keyboard |
|
|
|
return text, keyboard |
|
|
|
|
|
|
|
|
|
|
|
def edit_message_with_template(self, query: telebot.types.CallbackQuery, template: str, **kwargs): |
|
|
|
def edit_message_with_template(self, query: telebot.types.CallbackQuery, template: str, **kwargs): |
|
|
@ -224,6 +223,22 @@ class Bot(telebot.TeleBot): |
|
|
|
community.task_last_timestamps['scheduling'] = datetime.date.today() |
|
|
|
community.task_last_timestamps['scheduling'] = datetime.date.today() |
|
|
|
self.save_community(community) |
|
|
|
self.save_community(community) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def actions_loop(self): |
|
|
|
|
|
|
|
while True: |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
for community in self.iter_communities(): |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
self.run_necessary_actions_for_community(community) |
|
|
|
|
|
|
|
except KeyboardInterrupt as e: |
|
|
|
|
|
|
|
raise e |
|
|
|
|
|
|
|
except Exception: |
|
|
|
|
|
|
|
print(f'An exception occurred: {traceback.format_exc()}') |
|
|
|
|
|
|
|
except KeyboardInterrupt as e: |
|
|
|
|
|
|
|
raise e |
|
|
|
|
|
|
|
except Exception: |
|
|
|
|
|
|
|
print(f'An exception occurred while iterating through communities: {traceback.format_exc()}') |
|
|
|
|
|
|
|
time.sleep(60) |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|