def do_profile(self, name: str): if self.client is None: self.info('login first') return profile = None if name is None: identifier = g_facebook.current_user.identifier elif name.startswith('{') and name.endswith('}'): identifier = g_facebook.current_user.identifier profile = json.loads(name) else: identifier = g_facebook.identifier(name) if identifier is None: self.info('I don\'t understand.') return if profile: private_key = g_facebook.private_key_for_signature( identifier=g_facebook.current_user.identifier) assert private_key is not None, 'failed to get private key for client: %s' % self.client # create new profile and set all properties tai = Profile.new(identifier=identifier) for key in profile: tai.set_property(key, profile.get(key)) tai.sign(private_key=private_key) cmd = ProfileCommand.response(identifier=identifier, profile=tai) else: cmd = ProfileCommand.query(identifier=identifier) self.client.send_command(cmd=cmd)
def __response_meta(self) -> MetaCommand: gid = self.__group.identifier meta = self.__group.meta profile = self.__group.profile if profile is None: cmd = MetaCommand.response(identifier=gid, meta=meta) else: cmd = ProfileCommand.response(identifier=gid, profile=profile, meta=meta) return cmd