Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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.')
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 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