def send_login_response(self, username, password, nonce): ''' Called by protocol in response to a login_challenge event ''' password = password.lower()[:self.PASSWORD_MAX_LENGTH] if not isinstance(password, bytes): password = password.encode('utf8') if not isinstance(username, bytes): username = username.encode('utf8') res = myspace_auth_challenge_response(username, password, nonce) STA = 100 ID = 1 res = base64.b64encode(res) msg = msmsg(( ('login2', self.LOGINID), ('username', username), ('response', res), ('clientver', self.CLIENTVER), ('reconn', 0), ('status', STA), ('id', ID), )) self.send_msg(msg)
def deletebuddy(self, buddy_id): msg = msmsg(( ('delbuddy', ''), ('sesskey', self.sesskey), ('delprofileid', buddy_id), )) self.send_msg(msg)
def request_webchlg(self): msg = msmsg(( ('webchlg', ''), ('sesskey', self.sesskey), ('n', 0), )) self.send_msg(msg)
def addbuddy(self, buddy_id, reason): msg = msmsg(( ('addbuddy', ''), ('sesskey', self.sesskey), ('newprofileid', buddy_id), ('reason', reason), )) self.send_msg(msg)
def set_status(self, status_int, status_string, locstring): msg = msmsg(( ('status', status_int), ('sesskey', self.sesskey), ('statstring', status_string), ('locstring', locstring), )) self.send_msg(msg)
def send_typing(self, who, typing): msg = msmsg(( ('bm', BmMessage.Type.ActionMessage), ('sesskey', self.sesskey), ('t', who), ('cv', self.CLIENTVER), ('msg', '%typing%' if typing else '%stoptyping%'), )) self.send_msg(msg)
def logout(self): if self.sesskey is None: return msg = msmsg(( ('logout', ''), ('sesskey', self.sesskey), )) self.send_msg(msg)
def send_exitchat(self, who, gid): msg = msmsg(( ('bm', BmMessage.Type.ActionMessage), ('sesskey', self.sesskey), ('t', who), ('cv', self.CLIENTVER), ('gid', gid), ('msg', '!!!ExitChat'), )) self.send_msg(msg)
def send_im(self, who, message, callback=None): _message, message = message, msim_util.escape(message) msg = msmsg(( ('bm', BmMessage.Type.InstantMessage), ('sesskey', self.sesskey), ('t', who), ('cv', self.CLIENTVER), ('msg', message), )) try: self.send_msg(msg) except Exception, e: callback.error(e) raise
def _do_command(self, cmd, body): parts = [('persist', '1')] if self.use_sesskey: parts.append(('sesskey', self.proto.sesskey)) parts.append(('cmd', cmd)) parts.append(('dsn', self.dsn)) if self.use_uid: parts.append(('uid', self.proto.userid)) parts.append(('lid', self.lid)) parts.append(('body', body)) msg = msmsg(parts) return msg
def found_terminator(self): log.debug_s('in : %r %r', self.buffer, self.terminator) self.event('on_message', self, msmsg(self.buffer + self.terminator)) self.buffer = '' self.set_terminator(self.terminator)