Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    def deletebuddy(self, buddy_id):
        msg = msmsg((
            ('delbuddy', ''),
            ('sesskey', self.sesskey),
            ('delprofileid', buddy_id),
        ))

        self.send_msg(msg)
Beispiel #4
0
    def request_webchlg(self):
        msg = msmsg((
            ('webchlg', ''),
            ('sesskey', self.sesskey),
            ('n', 0),
        ))

        self.send_msg(msg)
Beispiel #5
0
    def deletebuddy(self, buddy_id):
        msg = msmsg((
            ('delbuddy', ''),
            ('sesskey', self.sesskey),
            ('delprofileid', buddy_id),
        ))

        self.send_msg(msg)
Beispiel #6
0
    def request_webchlg(self):
        msg = msmsg((
            ('webchlg', ''),
            ('sesskey', self.sesskey),
            ('n', 0),
        ))

        self.send_msg(msg)
Beispiel #7
0
    def addbuddy(self, buddy_id, reason):
        msg = msmsg((
            ('addbuddy', ''),
            ('sesskey', self.sesskey),
            ('newprofileid', buddy_id),
            ('reason', reason),
        ))

        self.send_msg(msg)
Beispiel #8
0
    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)
Beispiel #9
0
 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)
Beispiel #10
0
 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)
Beispiel #11
0
    def addbuddy(self, buddy_id, reason):
        msg = msmsg((
            ('addbuddy', ''),
            ('sesskey', self.sesskey),
            ('newprofileid', buddy_id),
            ('reason', reason),
        ))

        self.send_msg(msg)
Beispiel #12
0
    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)
Beispiel #13
0
    def logout(self):
        if self.sesskey is None:
            return

        msg = msmsg((
            ('logout', ''),
            ('sesskey', self.sesskey),
        ))

        self.send_msg(msg)
Beispiel #14
0
 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)
Beispiel #15
0
    def logout(self):
        if self.sesskey is None:
            return

        msg = msmsg((
                     ('logout', ''),
                     ('sesskey', self.sesskey),
                     ))

        self.send_msg(msg)
Beispiel #16
0
 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)
Beispiel #17
0
    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
Beispiel #18
0
    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
Beispiel #19
0
    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
Beispiel #20
0
    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
Beispiel #21
0
 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)