cmd: Optional[dict] = None, title: Optional[str] = None): if cmd is None: super().__init__(command=ReportCommand.REPORT) else: super().__init__(cmd=cmd) if title is not None: self['title'] = title # # report title # @property def title(self) -> str: return self.get('title') @title.setter def title(self, value: str): self['title'] = value # register Command.register(command=ReportCommand.REPORT, factory=CommandFactoryBuilder(command_class=ReportCommand)) Command.register(command='broadcast', factory=CommandFactoryBuilder(command_class=ReportCommand)) Command.register(command=ReportCommand.ONLINE, factory=CommandFactoryBuilder(command_class=ReportCommand)) Command.register(command=ReportCommand.OFFLINE, factory=CommandFactoryBuilder(command_class=ReportCommand))
return self.__users @users.setter def users(self, value: List[ID]): if value is None: self.pop('users', None) else: self['users'] = ID.revert(members=value) self.__users = value # # User's meta map # @property def results(self) -> dict: return self.get('results') @results.setter def results(self, value: dict): if value is None: self.pop('results', None) else: self['results'] = value # register Command.register(command=SearchCommand.SEARCH, factory=CommandFactoryBuilder(command_class=SearchCommand)) Command.register(command=SearchCommand.ONLINE_USERS, factory=CommandFactoryBuilder(command_class=SearchCommand))
Create search command :param content: command info :param keywords: search number, ID, or 'users' :param users: user ID list :param results: user meta map :return: SearchCommand object """ if content is None: # create empty content content = {} # new SearchCommand(dict) if keywords is None: command = cls.SEARCH elif keywords == cls.SEARCH or keywords == cls.ONLINE_USERS: command = keywords else: command = cls.SEARCH content['keywords'] = keywords if users is not None: content['users'] = users if results is not None: content['results'] = results return super().new(content=content, command=command) # register command class Command.register(command=SearchCommand.SEARCH, command_class=SearchCommand) Command.register(command=SearchCommand.ONLINE_USERS, command_class=SearchCommand)