def __init__(self, *args, is_queued_def=True, mqueue=None, **kwargs): super().__init__(*args, **kwargs) self._is_messages_queued_default = is_queued_def self._msg_queue = mqueue or mq.MessageQueue() chats = TBDB.get_chats() self.active_chats_cache = dict( zip([c['chat_id'] for c in chats], [c['active'] for c in chats]))
def __post(): chats = TBDB.get_chats() sent = 0 for chat in chats: try: bot.send_message(chat_id=chat['chat_id'], text=text, parse_mode='html', is_group=int(chat['chat_id']) < 0) sent += 1 time.sleep(0.1) except Exception as e: logger.error("Exception sending broadcast to %d: (%s) %s", chat['chat_id'], e, traceback.format_exc()) bot.send_message(chat_id=chat_id, text='Broadcast sent to {}/{} chats'.format( sent, len(chats)), is_group=chat_id < 0) TranscriberBot.get().command_handlers['users'](bot, update)