def __init__(self): super().__init__() # delegate for send message self.messenger: Messenger = None # group gid = g_facebook.identifier(group_naruto) self.__group: Group = g_facebook.group(gid)
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 do_login(self, name: str): sender = g_facebook.identifier(name) if sender is None: self.info('unknown user: %s' % name) else: self.info('login as %s' % sender) self.login(identifier=sender) self.prompt = Console.prompt + sender.name + '$ '
def do_call(self, name: str): if self.client is None: self.info('login first') return receiver = g_facebook.identifier(name) if receiver is None: self.info('unknown user: %s' % name) else: meta = g_facebook.meta(identifier=receiver) self.info('talking with %s now, meta=%s' % (receiver, meta)) # switch receiver self.receiver = receiver