def photo_handler(self, update, context): ''' Photo handler ''' from_user = str(update.message.from_user) username = update.effective_user.username src_type = get_user_permission(self.database, username) # Disable train mode for user if src_type == 'user': self.state[from_user] = 'Predict' TelegramClient.photo_handler(self, update, context)
def __init__(self, database, num_workers=None): # TelegramClient will use all new handlers with permission check if num_workers: TelegramClient.__init__(self, num_workers) else: TelegramClient.__init__(self) self.database = database self.import_root_user() dispatcher = self.updater.dispatcher dispatcher.add_handler( CallbackQueryHandler(self.callback_query_handler)) dispatcher.add_handler( CommandHandler('admin', self.list_admin)) dispatcher.add_handler( CommandHandler('user', self.list_user)) dispatcher.add_handler( CommandHandler('addadmin', self.add_admin)) dispatcher.add_handler( CommandHandler('adduser', self.add_user))
async def setUpClass(cls): telegram_client = TelegramClient() # A hack to ensure dispatcher exist Dispatcher._set_singleton( # pylint: disable=W0212 telegram_client.updater.dispatcher) # pylint: disable=W0212 database_handle = Database(testing=True) database_handle.drop_testing_database() cls.client = Client(database_handle, telegram_client) cls.client.start() cls.user = TelegramUser() await cls.user.start() await cls.user.setup_chat()
def retrain_command_handler(self, update, context): TelegramClient.retrain_command_handler(update, context)
def note_command_handler(self, update, context): ''' Note command ''' TelegramClient.note_command_handler(self, update, context)
def done_command_handler(self, update, context): ''' Done command ''' TelegramClient.done_command_handler(self, update, context)
def train_command_handler(self, update, context): ''' Train command ''' TelegramClient.train_command_handler(self, update, context)
def mention_handler(self, update, context): ''' Mention handler ''' TelegramClient.mention_handler(self, update, context)
def error_handler(self, update, context): ''' Error handler ''' TelegramClient.error_handler(self, update, context)