def do_search(self, keywords: str): if self.client is None: self.info('login first') return cmd: Command = Command(command='search') cmd['keywords'] = keywords self.client.send_command(cmd=cmd)
def do_show(self, name: str): if self.client is None: self.info('login first') return if 'users' == name: cmd: Command = Command(command='users') self.client.send_command(cmd=cmd) else: self.info('I don\'t understand.')
def contacts_command(self, identifier: ID) -> Command: cmd = self.__contacts_commands.get(identifier) if cmd is None: path = self.__contacts_command_path(identifier=identifier) self.info('Loading stored contacts command from: %s' % path) dictionary = self.read_json(path=path) if dictionary is not None: cmd = Command(dictionary) self.__contacts_commands[identifier] = cmd return cmd
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(command=BlockCommand.BLOCK) res['list'] = [] return res
def __get(self, sender: ID) -> Content: 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(command=MuteCommand.MUTE) res['list'] = [] return res
def contacts_command(self, identifier: ID) -> Optional[Command]: # try from memory cache cmd = self.__contacts_commands.get(identifier) if cmd is None: # try from local storage path = self.__contacts_command_path(identifier=identifier) self.info('Loading stored contacts command from: %s' % path) dictionary = self.read_json(path=path) if dictionary is None: cmd = self.__empty else: cmd = Command(dictionary) self.__contacts_commands[identifier] = cmd if cmd is not self.__empty: return cmd