Пример #1
0
 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)
Пример #2
0
 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))
Пример #3
0
 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()
Пример #4
0
 def retrain_command_handler(self, update, context):
     TelegramClient.retrain_command_handler(update, context)
Пример #5
0
 def note_command_handler(self, update, context):
     ''' Note command '''
     TelegramClient.note_command_handler(self, update, context)
Пример #6
0
 def done_command_handler(self, update, context):
     ''' Done command '''
     TelegramClient.done_command_handler(self, update, context)
Пример #7
0
 def train_command_handler(self, update, context):
     ''' Train command '''
     TelegramClient.train_command_handler(self, update, context)
Пример #8
0
 def mention_handler(self, update, context):
     ''' Mention handler '''
     TelegramClient.mention_handler(self, update, context)
Пример #9
0
 def error_handler(self, update, context):
     ''' Error handler '''
     TelegramClient.error_handler(self, update, context)