|
|
|
@ -53,8 +53,7 @@ class Bot(telebot.TeleBot):
|
|
|
|
|
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, keyboard = self.templates.separate_text_and_keyboards(text) |
|
|
|
|
keyboard = utils.create_keyboard(keyboard) if keyboard is not None \ |
|
|
|
|
else self.main_keyboard.get(user.locale, self.main_keyboard.get('ru')) |
|
|
|
|
keyboard = utils.create_keyboard(keyboard) |
|
|
|
|
return text, keyboard |
|
|
|
|
|
|
|
|
|
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() |
|
|
|
|
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): |
|
|
|
|
if isinstance(message, telebot.types.CallbackQuery): |
|
|
|
|
message = message.message |
|
|
|
|