Example #1
0
    def prepare_connect(self):
        """ Gather necessary connection parameters before attempting to connect. """
        if self.account and self.password:
            log.info('Deleting old login cookies.')
            tinychat.delete_login_cookies()
            if len(self.account) > 3:
                log.info('Trying to log in with account: %s' % self.account)
                login = tinychat.post_login(self.account, self.password)
                if 'pass' in login['cookies']:
                    log.info('Logged in as: %s Cookies: %s' % (self.account, login['cookies']))
                    self.console_write(COLOR['green'], 'Logged in as: ' + login['cookies']['user'])
                else:
                    self.console_write(COLOR['red'], 'Log in Failed')
                    self.account = raw_input('Enter account: (optional)')
                    if self.account:
                        self.password = raw_input('Enter password: ')
                    self.prepare_connect()
            else:
                self.console_write(COLOR['red'], 'Account name is to short.')
                self.account = raw_input('Enter account: ')
                self.password = raw_input('Enter password: ')
                self.prepare_connect()

        config = tinychat.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: ')
            if not self.room_pass:
                self._roomname = raw_input('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.get_roomconfig_xml(self._roomname, self.room_pass, proxy=self._proxy)
                if config != 'PW':
                    break
                else:
                    self.console_write(COLOR['red'], 'Password Failed.')

        if SETTINGS['debug_mode']:
            for k in config:
                self.console_write(COLOR['white'], k + ': ' + str(config[k]))

        log.info('RTMP info found: %s' % config)
        self._ip = config['ip']
        self._port = config['port']
        self._tc_url = config['tcurl']
        self._app = config['app']
        self._room_type = config['roomtype']
        self._greenroom = config['greenroom']
        self._b_password = config['bpassword']

        self.console_write(COLOR['white'], '============ CONNECTING ============\n\n')
        self.connect()
Example #2
0
 def auto_job_handler(self):
     """ The event handler for auto_job_timer. """
     if self.is_connected:
         conf = tinychat.get_roomconfig_xml(self._roomname, self.room_pass, proxy=self._proxy)
         if conf is not None:
             if self._is_client_mod:
                 self._greenroom = conf['greenroom']
                 self._b_password = conf['bpassword']
         log.info('recv configuration: %s' % conf)
     self.start_auto_job_timer()