コード例 #1
0
ファイル: tinychat.py プロジェクト: Anonymousx12/pinylib
 def start_auto_job_timer(self):
     """
     Just like using tinychat with a browser, this method will
     fetch the room config from tinychat API every 5 minute.
     See line 228 at http://tinychat.com/embed/chat.js
     """
     ts_now = int(time.time())
     while True:
         counter = int(time.time())
         if counter == ts_now + 300:  # 300 seconds = 5 minutes
             if self.is_connected:
                 tinychat_api.get_roomconfig_xml(self.roomname, self.room_pass, proxy=self.proxy)
             self.start_auto_job_timer()
             break
コード例 #2
0
ファイル: tinychat.py プロジェクト: CrookedTech/pinylib
 def start_auto_job_timer(self):
     """
     Just like using tinychat with a browser, this method will
     fetch the room config from tinychat API every 5 minute.
     See line 228 at http://tinychat.com/embed/chat.js
     """
     ts_now = int(time.time())
     while True:
         counter = int(time.time())
         if counter == ts_now + 300:  # 300 seconds = 5 minutes
             if self.is_connected:
                 tinychat_api.get_roomconfig_xml(self.roomname,
                                                 self.room_pass,
                                                 proxy=self.proxy)
             self.start_auto_job_timer()
             break
コード例 #3
0
ファイル: tinychat.py プロジェクト: Anonymousx12/pinylib
    def prepare_connect(self):
        """ Gather necessary connection parameters before attempting to connect. """
        if self.is_reconnected and self.account and self.password:
            # Not sure about this. But from what ive gathered, the cookies doesn't change, however they might expire.
            # The hashes on the other hand do change..
            # Try parsing a new set of hashes.
            hashes = web_request.find_hashes(self.embed_url, proxy=self.proxy)
            self.autoop = hashes['autoop']
            self.prokey = hashes['prohash']
        else:
            if self.account and self.password:
                if len(self.account) > 3:
                    login = web_request.post_login(self.account, self.password)
                    if 'pass' in login['cookies']:
                        console_write([COLOR['green'], 'Logged in as: ' + login['cookies']['user'], self.roomname])
                        hashes = web_request.find_hashes(self.embed_url, proxy=self.proxy)
                        self.autoop = hashes['autoop']
                        self.prokey = hashes['prohash']
                    else:
                        console_write([COLOR['red'], 'Log in Failed', self.roomname])
                        self.account = raw_input('Enter account: (optional)')
                        if self.account:
                            self.password = raw_input('Enter password: '******'red'], 'Account name is to short.', self.roomname])
                    self.account = raw_input('Enter account: ')
                    self.password = raw_input('Enter password: '******'white'], 'Parsing room config xml...', self.roomname])
        config = tinychat_api.get_roomconfig_xml(self.roomname, self.room_pass, proxy=self.proxy)
        while config == 'PW':
            self.room_pass = raw_input('The room is password protected. Enter room password: '******'Enter room name: ')
                self.room_pass = raw_input('Enter room pass: (optional)')
                self.account = raw_input('Enter account: (optional)')
                self.password = raw_input('Enter password: (optional)')
                self.prepare_connect()
            else:
                config = tinychat_api.get_roomconfig_xml(self.roomname, self.room_pass, proxy=self.proxy)
                if config != 'PW':
                    break
                else:
                    console_write([COLOR['red'], 'Password Failed.', self.roomname])

        self.ip = config['ip']
        self.port = config['port']
        self.tc_url = config['tcurl']
        self.app = config['app']
        self.roomtype = config['roomtype']
        self.greenroom = config['greenroom']

        console_write([COLOR['white'],
                       'TC Url: ' + self.tc_url + '\n' +
                       'Application: ' + self.app + '\n' +
                       'Room type: ' + self.roomtype + '\n' +
                       'Greenroom: ' + str(self.greenroom) + '\n\n' +
                       '============ CONNECTING ============\n', self.roomname])
        self.connect()
コード例 #4
0
ファイル: tinychat.py プロジェクト: CrookedTech/pinylib
    def prepare_connect(self):
        """ Gather necessary connection parameters before attempting to connect. """
        if self.is_reconnected and self.account and self.password:
            # Not sure about this. But from what ive gathered, the cookies doesn't change, however they might expire.
            # The hashes on the other hand do change..
            # Try parsing a new set of hashes.
            hashes = web_request.find_hashes(self.embed_url, proxy=self.proxy)
            self.autoop = hashes['autoop']
            self.prokey = hashes['prohash']
        else:
            if self.account and self.password:
                if len(self.account) > 3:
                    login = web_request.post_login(self.account, self.password)
                    if 'pass' in login['cookies']:
                        console_write([
                            COLOR['green'],
                            'Logged in as: ' + login['cookies']['user'],
                            self.roomname
                        ])
                        hashes = web_request.find_hashes(self.embed_url,
                                                         proxy=self.proxy)
                        self.autoop = hashes['autoop']
                        self.prokey = hashes['prohash']
                    else:
                        console_write(
                            [COLOR['red'], 'Log in Failed', self.roomname])
                        self.account = raw_input('Enter account: (optional)')
                        if self.account:
                            self.password = raw_input('Enter password: '******'red'], 'Account name is to short.',
                        self.roomname
                    ])
                    self.account = raw_input('Enter account: ')
                    self.password = raw_input('Enter password: '******'white'], 'Parsing room config xml...', self.roomname])
        config = tinychat_api.get_roomconfig_xml(self.roomname,
                                                 self.room_pass,
                                                 proxy=self.proxy)
        while config == 'PW':
            self.room_pass = raw_input(
                'The room is password protected. Enter room password: '******'Enter room name: ')
                self.room_pass = raw_input('Enter room pass: (optional)')
                self.account = raw_input('Enter account: (optional)')
                self.password = raw_input('Enter password: (optional)')
                self.prepare_connect()
            else:
                config = tinychat_api.get_roomconfig_xml(self.roomname,
                                                         self.room_pass,
                                                         proxy=self.proxy)
                if config != 'PW':
                    break
                else:
                    console_write(
                        [COLOR['red'], 'Password Failed.', self.roomname])

        self.ip = config['ip']
        self.port = config['port']
        self.tc_url = config['tcurl']
        self.app = config['app']
        self.roomtype = config['roomtype']
        self.greenroom = config['greenroom']

        console_write([
            COLOR['white'], 'TC Url: ' + self.tc_url + '\n' + 'Application: ' +
            self.app + '\n' + 'Room type: ' + self.roomtype + '\n' +
            'Greenroom: ' + str(self.greenroom) + '\n\n' +
            '============ CONNECTING ============\n', self.roomname
        ])
        self.connect()