예제 #1
0
    def auth(self):
        auth_data = masterserver.auth(self.config.nick, self.config.password)
        if 'ip' not in auth_data or 'auth_hash' not in auth_data:
            print("Login Failure")
            return False
        # print json.dumps(auth_data, indent=4)

        self.ip = auth_data['ip']
        self.cookie = auth_data['cookie']
        self.account_id = int(auth_data['account_id'])
        self.auth_hash = auth_data['auth_hash']
        self.got_len = False
        self.nick = auth_data['nickname']
        self.id2nick[self.account_id] = self.nick
        self.nick2id[self.nick] = self.account_id
        if "clan_member_info" in auth_data:
            self.clan_info = auth_data["clan_member_info"]
        else:
            self.clan_info = {}
        if "clan_roster" in auth_data and "error" not in auth_data[
                "clan_roster"]:
            self.clan_roster = auth_data["clan_roster"]
        else:
            self.clan_roster = {}
        if "buddy_list" in auth_data:
            buddy_list = auth_data["buddy_list"]
        else:
            buddy_list = {}
        self.buddy_list = {}
        for id in self.clan_roster:
            if self.clan_roster[id]['nickname']:
                nick = normalize_nick(self.clan_roster[id]['nickname']).lower()
            self.id2nick[id] = nick
            self.nick2id[nick] = id
        for buddies in buddy_list.values():
            for buddy in buddies.values():
                try:
                    id = int(buddy['buddy_id'])
                    self.buddy_list[id] = buddy
                    nick = normalize_nick(buddy['nickname'])
                    self.id2nick[id] = nick
                    self.nick2id[nick] = id
                except:
                    pass
        return auth_data
예제 #2
0
파일: bot.py 프로젝트: dezgeg/pyHoNBot
    def auth(self):
        auth_data = masterserver.auth(self.config.nick,self.config.password)
        if 'ip' not in auth_data or 'auth_hash' not in auth_data:
            print("Login Failure")
            return False
        # print json.dumps(auth_data, indent=4)

        self.ip = auth_data['ip']
        self.cookie = auth_data['cookie']
        self.account_id = int(auth_data['account_id'])
        self.auth_hash = auth_data['auth_hash']
        self.got_len = False
        self.nick = auth_data['nickname']
        self.id2nick[self.account_id] = self.nick
        self.nick2id[self.nick] = self.account_id
        if "clan_member_info" in auth_data:
            self.clan_info = auth_data["clan_member_info"]
        else:
            self.clan_info = {}
        if "clan_roster" in auth_data and "error" not in auth_data["clan_roster"]:
            self.clan_roster = auth_data["clan_roster"]
        else:
            self.clan_roster = {}
        if "buddy_list" in auth_data:
            buddy_list = auth_data["buddy_list"]
        else:
            buddy_list = {}
        self.buddy_list = {}
        for id in self.clan_roster:
            if self.clan_roster[id]['nickname']:
                nick = normalize_nick(self.clan_roster[id]['nickname']).lower()
            self.id2nick[id] = nick
            self.nick2id[nick] = id
        for buddies in buddy_list.values():
            for buddy in buddies.values():
                try:
                    id = int(buddy['buddy_id'])
                    self.buddy_list[id] = buddy
                    nick = normalize_nick(buddy['nickname'])
                    self.id2nick[id] = nick
                    self.nick2id[nick] = id
                except:pass
        return auth_data
예제 #3
0
 def run(self):
     auth_data = masterserver.auth(self.config.nick, self.config.password)
     print('got auth data')
     #print auth_data,self.config.nick,self.config.password
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.ip = auth_data['ip']
     self.cookie = auth_data['cookie']
     self.account_id = int(auth_data['account_id'])
     self.auth_hash = auth_data['auth_hash']
     self.got_len = False
     self.nick = auth_data['nickname']
     if "clan_member_info" in auth_data:
         self.clan_info = auth_data["clan_member_info"]
     else:
         self.clan_info = {}
     if "clan_roster" in auth_data and "error" not in auth_data[
             "clan_roster"]:
         self.clan_roster = auth_data["clan_roster"]
     else:
         self.clan_roster = {}
     if "buddy_list" in auth_data:
         buddy_list = auth_data["buddy_list"]
     else:
         buddy_list = {}
     self.buddy_list = {}
     for id in self.clan_roster:
         nick = normalize_nick(self.clan_roster[id]['nickname'])
         self.id2nick[id] = nick
         self.nick2id[nick] = id
     for buddies in buddy_list.values():
         for buddy in buddies.values():
             id = int(buddy['buddy_id'])
             nick = normalize_nick(buddy['nickname'])
             self.id2nick[id] = nick
             self.nick2id[nick] = id
             self.buddy_list[id] = buddy
     self.connect((auth_data['chat_url'], packets.ID.HON_CHAT_PORT))
     asyncore.loop()
예제 #4
0
파일: bot.py 프로젝트: Theino/pyHoNBot
 def run(self):
     auth_data = masterserver.auth(self.config.nick,self.config.password)
     print ('got auth data')
     #print auth_data,self.config.nick,self.config.password
     self.create_socket( socket.AF_INET, socket.SOCK_STREAM )
     self.ip = auth_data['ip']
     self.cookie = auth_data['cookie']
     self.account_id = int(auth_data['account_id'])
     self.auth_hash = auth_data['auth_hash']
     self.got_len = False
     self.nick = auth_data['nickname']
     if "clan_member_info" in auth_data:
         self.clan_info = auth_data["clan_member_info"]
     else:
         self.clan_info = {}
     if "clan_roster" in auth_data and "error" not in auth_data["clan_roster"]:
         self.clan_roster = auth_data["clan_roster"]
     else:
         self.clan_roster = {}
     if "buddy_list" in auth_data:
         buddy_list = auth_data["buddy_list"]
     else:
         buddy_list = {}
     self.buddy_list = {}
     for id in self.clan_roster:
         nick = normalize_nick(self.clan_roster[id]['nickname'])
         self.id2nick[id] = nick
         self.nick2id[nick] = id
     for buddies in buddy_list.values():
         for buddy in buddies.values():
             id = int(buddy['buddy_id'])
             nick = normalize_nick(buddy['nickname'])
             self.id2nick[id] = nick
             self.nick2id[nick] = id
             self.buddy_list[id] = buddy
     self.connect( ( auth_data['chat_url'], packets.ID.HON_CHAT_PORT ) )
     asyncore.loop()