def do_search(self, keywords: str): if self.client is None: self.info('login first') return cmd: Command = Command.new(command='search') cmd['keywords'] = keywords self.client.send_command(cmd=cmd)
def __search(self, keywords: list) -> Optional[Content]: results = self.database.search(keywords=keywords) users = list(results.keys()) response = Command.new(command='search') response['message'] = '%d user(s) found' % len(users) response['users'] = users response['results'] = results return response
def do_show(self, name: str): if self.client is None: self.info('login first') return if 'users' == name: cmd: Command = Command.new(command='users') self.client.send_command(cmd=cmd) else: self.info('I don\'t understand.')
def __get(self, sender: ID) -> Content: stored: Command = self.database.block_command(identifier=sender) if stored is not None: # response the stored block command directly return stored else: # return TextContent.new(text='Sorry, block-list of %s not found.' % sender) # TODO: here should response an empty HistoryCommand: 'block' res = Command.new(command='block') res['list'] = [] return res
def __get(self, sender: ID) -> Content: self.info('search mute-list for %s' % sender) stored: Command = self.database.mute_command(identifier=sender) if stored is not None: # response the stored mute command directly return stored else: # return TextContent.new(text='Sorry, mute-list of %s not found.' % sender) # TODO: here should response an empty HistoryCommand: 'mute' res = Command.new(command='mute') res['list'] = [] return res
def __random_users(self, max_count=20) -> Optional[Content]: users = self.session_server.random_users(max_count=max_count) response = Command.new(command='users') response['message'] = '%d user(s) connected' % len(users) response['users'] = users return response