def _on_show_clubhouse(self, manager, result): val = result.get_js_value() if val.is_undefined(): raise ValueError('needs character argument') if not val.is_string(): raise ValueError('character arg should be string') character_name = val.to_string() Clubhouse.show_clubhouse(character_name)
def fake_login(update: Update, context: CallbackContext) -> int: user = update.message.from_user logger.info("{}: fake_name {}".format(user.id, update.message.text)) Clubhouse(user_id=context.user_data['user_id'], user_token=context.user_data['user_token'], user_device=context.user_data['user_device']).update_name(update.message.text) update.message.reply_html('Please enter fake user login (ivanpetrov1988) or /cancel') return FAKE_LOGIN
def _on_load_state_finish(self, proxy, result, user_data): val = None try: val = proxy.call_finish(result) except GLib.Error as err: if (Gio.dbus_error_get_remote_error(err) != 'com.hack_computer.GameStateService.KeyError'): print("Error loading game state: %s" % err.message) if val is not None: json = GLib.strescape(val.unpack()[0]) js = 'if(typeof loadState === "function"){loadState(JSON.parse("%s"));}' % json self.view.run_javascript(js) else: self.view.run_javascript( 'if(typeof loadState === "function"){loadState();}') Clubhouse.property_connect('RunningQuest', self._on_running_quest_change)
def main(): """ Initialize required configurations, start with some basic stuff. """ # Initialize configuration client = None user_config = read_config() user_id = user_config.get('user_id') user_token = user_config.get('user_token') user_device = user_config.get('user_device') # Check if user is authenticated if user_id and user_token and user_device: client = Clubhouse(user_id=user_id, user_token=user_token, user_device=user_device) chat_main(client) else: client = Clubhouse() user_authentication(client) main()
def main(): """ Initialize required configurations, start with some basic stuff. """ # Initialize configuration client = None user_config = read_config() user_id = user_config.get('user_id') user_token = user_config.get('user_token') user_device = user_config.get('user_device') # Check if user is authenticated if user_id and user_token and user_device: client = Clubhouse(user_id=user_id, user_token=user_token, user_device=user_device) # Check if user is still on the waitlist _check = client.check_waitlist_status() if _check['is_waitlisted']: print( "[!] You're still on the waitlist. Find your friends to get yourself in." ) return # Check if user has not signed up yet. _check = client.me() if not _check['user_profile'].get("username"): process_onboarding(client) chat_main(client) else: client = Clubhouse() user_authentication(client) main()
def user_authentication(client): """ (Clubhouse) -> NoneType Just for authenticating the user. """ result = None while True: user_phone_number = input( "[.] Please enter your phone number. (+818043217654) > ") result = client.start_phone_number_auth(user_phone_number) if not result['success']: print( f"[-] Error occured during authentication. ({result['error_message']})" ) continue break result = None while True: verification_code = input( "[.] Please enter the SMS verification code (1234, 0000, ...) > ") result = client.complete_phone_number_auth(user_phone_number, verification_code) if not result['success']: print( f"[-] Error occured during authentication. ({result['error_message']})" ) continue break user_id = result['user_profile']['user_id'] user_token = result['auth_token'] user_device = client.HEADERS.get("CH-DeviceId") write_config(user_id, user_token, user_device) print("[.] Writing configuration file complete.") if result['is_waitlisted']: print( "[!] You're still on the waitlist. Find your friends to get yourself in." ) return # Authenticate user first and start doing something client = Clubhouse(user_id=user_id, user_token=user_token, user_device=user_device) if result['is_onboarding']: process_onboarding(client) return
def final(update: Update, context: CallbackContext) -> int: user = update.message.from_user logger.info("{}: fake_login {}".format(user.id, update.message.text)) Clubhouse(user_id=context.user_data['user_id'], user_token=context.user_data['user_token'], user_device=context.user_data['user_device']).update_username(update.message.text) config = configparser.ConfigParser() config.read('settings.ini') config['Clubhouse'] = {'user_device': context.user_data['user_device'], 'user_id': context.user_data['user_id'], 'user_token': context.user_data['user_token']} with open('settings.ini', 'w') as configfile: config.write(configfile) update.message.reply_html('All done.') return ConversationHandler.END
def process_queue(): while True: try: for task in QUEUE.find().batch_size(5): event_id = task['_id'] users = task['users'] if task['time_start'] - datetime.now(timezone.utc) < timedelta( minutes=20): logger.debug(f'Tick-tock for {event_id}') config = configparser.ConfigParser() config.read('settings.ini') data = Clubhouse( user_id=config['Clubhouse']['user_id'], user_token=config['Clubhouse']['user_token'], user_device=config['Clubhouse'] ['user_device']).get_event(event_hashid=event_id) if data.get('success'): ev = data['event'] room_id = ev['channel'] topic = ev['name'] if ev['is_expired']: logger.warning('Event expired!') QUEUE.delete_one({'_id': event_id}) for user in users: logger.info(f'Informing {user}') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram']['token'] ).bot.send_message( chat_id=user, text= f'Event <b>{topic}</b> has either expired or we were banned by clubhouse', parse_mode='html') except telegram.error.Unauthorized: logger.warning(f'{user} banned the bot!') elif ev['is_member_only']: logger.warning('Private!') QUEUE.delete_one({'_id': event_id}) for user in users: logger.info(f'Informing {user}') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram']['token'] ).bot.send_message( chat_id=user, text= f'Event <b>{topic}</b> is private, we cannot record it.', parse_mode='html') except telegram.error.Unauthorized: logger.warning(f'{user} banned the bot!') elif room_id: logger.info(f'Got room_id {room_id}') cur_task = TASKS.find_one({'_id': room_id}) if cur_task: logger.info('We already know about that room') TASKS.update_one( {'_id': room_id}, {'$addToSet': { 'users': users }}) QUEUE.delete_one({'_id': event_id}) for user in users: logger.info(f'Informing {user}') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram']['token'] ).bot.send_message( chat_id=user, text= f'Event <b>{topic}</b> has started. Preparing to record that room. Because of some new limits from Clubhouse that can take some time.', parse_mode='html') except telegram.error.Unauthorized: logger.warning( f'{user} banned the bot!') else: logger.error(f'{room_id}: New') TASKS.insert_one({ '_id': room_id, 'status': 'WAITING_FOR_TOKEN', 'topic': topic, 'users': users, 'dt': datetime.utcnow() }) QUEUE.delete_one({'_id': event_id}) for user in users: logger.info(f'Informing {user}') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram']['token'] ).bot.send_message( chat_id=user, text= f'Event <b>{topic}</b> has started. Preparing to record that room. Because of some new limits from Clubhouse that can take some time.', parse_mode='html') except telegram.error.Unauthorized: logger.warning( f'{user} banned the bot!') else: QUEUE.delete_one({'_id': event_id}) logger.critical('NO TOKEN! BAN???') for user in users: logger.info(f'Informing {user}') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram'] ['token']).bot.send_message( chat_id=user, text=f'Failed to get event {event_id}', parse_mode='html') except telegram.error.Unauthorized: logger.warning(f'{user} banned the bot!') sleep(15) elif datetime.now( timezone.utc) - task['time_start'] > timedelta( minutes=20): logger.warning('Event expired by timeout!') QUEUE.delete_one({'_id': event_id}) except: logger.critical('process_queue has broken') print(traceback.format_exc()) sleep(30)
def process_token(): while True: sleep(5) try: for task in TASKS.find({'status': 'WAITING_FOR_TOKEN'}): room_id = task['_id'] logger.info(f'Need token for {room_id}') config = configparser.ConfigParser() config.read('settings.ini') data = Clubhouse(user_id=config['Clubhouse']['user_id'], user_token=config['Clubhouse']['user_token'], user_device=config['Clubhouse'] ['user_device']).join_channel(room_id) users = task['users'] if data.get('success'): token = data['token'] topic = data['topic'] logger.debug(f'Got token for {room_id}: {token}') TASKS.update_one({'_id': room_id}, { '$set': { 'token': token, 'topic': topic, 'status': 'GOT_TOKEN' } }) for user in users: logger.info(f'Informing {user} about token') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram']['token'] ).bot.send_message( chat_id=user, text= f"Recording <b>{topic}</b>. We'll notify you as soon as it's over.", parse_mode='html') except telegram.error.Unauthorized: logger.warning(f'{user} banned the bot!') sleep(5) config = configparser.ConfigParser() config.read('settings.ini') Clubhouse(user_id=config['Clubhouse']['user_id'], user_token=config['Clubhouse']['user_token'], user_device=config['Clubhouse'] ['user_device']).leave_channel(room_id) elif 'This room is no longer available' in data.get( 'error_message', ''): for user in users: logger.info(f'Informing {user}') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram']['token'] ).bot.send_message( chat_id=user, text= f'Planned event has either expired or we were banned by clubhouse. Sorry :(', parse_mode='html') except telegram.error.Unauthorized: logger.warning(f'{user} banned the bot!') TASKS.delete_one({'_id': room_id}) else: TASKS.delete_one({'_id': room_id}) logger.critical('NO TOKEN! BAN???') for user in users: logger.info(f'Informing {user}') try: config = configparser.ConfigParser() config.read('settings.ini') Updater( config['Telegram']['token']).bot.send_message( chat_id=user, text=f'This is probably ban', parse_mode='html') except telegram.error.Unauthorized: logger.warning(f'{user} banned the bot!') sleep(25) except: logger.critical('process_token has broken') print(traceback.format_exc())
def event_msg(update: Update, context: CallbackContext) -> None: config = configparser.ConfigParser() config.read('settings.ini') WHITE_LIST = config['Telegram']['white_list'].split(',') if str(update.message.chat_id) not in WHITE_LIST: logger.warning(f'Unknown user {update.message.chat_id}') update.message.reply_html( f"We are under ban from Clubhouse. Check https://www.reddit.com/r/ClubhouseApp/comments/lqi79i/recording_clubhouse_crash_course/") return event_id = urllib.parse.urlparse(update.message.text).path.split('/')[-1] logger.info(f'EVENT from {update.message.chat_id}: {event_id}') client = Clubhouse( user_id=config['Clubhouse']['user_id'], user_token=config['Clubhouse']['user_token'], user_device=config['Clubhouse']['user_device'] ) data = client.get_event(event_hashid=event_id) if data.get('success', False): logger.debug('Found an event.') ev = data['event'] room_id = ev['channel'] topic = ev['name'] time_start = datetime.fromisoformat(ev['time_start']).astimezone(pytz.utc) if ev['is_expired']: logger.warning(f'This event has expired: {event_id}') update.message.reply_text('This event has expired.') elif ev['is_member_only']: logger.warning(f'This event is private: {event_id}') update.message.reply_text('This event is private.') elif room_id: cur_task = TASKS.find_one({'_id': room_id}) if cur_task: logger.debug('We already know about that room') TASKS.update_one({ '_id': room_id }, { '$addToSet': {'users': update.message.chat_id} }) logger.info(f'Added {update.message.chat_id} to ROOM {room_id}') update.message.reply_html(f"Recording <b>{topic}</b>. We'll notify you as soon as it's over.") else: logger.info(f'{room_id}: New event') TASKS.insert_one({'_id': room_id, 'status': 'WAITING_FOR_TOKEN', 'dt': datetime.utcnow(), 'users': [update.message.chat_id] }) update.message.reply_html( f"Preparing to record that room. Because of some new limits from Clubhouse that can take some time.") else: QUEUE.update_one({'_id': event_id}, {'$set': {'time_start': time_start}, '$addToSet': {'users': update.message.chat_id}}, upsert=True) logger.info(f'New event {event_id}') update.message.reply_html(f"Looking forward for <b>{topic}</b>. We'll notify you as soon as it's over.") elif 'detail' in data: logger.warning(f'ERROR {event_id} BAN') update.message.reply_text('This is BAN') else: logger.warning(f'ERROR {event_id} ' + data.get('error_message')) update.message.reply_text('Clubhouse said: ' + data.get('error_message', 'This event is not active'))
dispatcher.add_handler(CommandHandler("start", start)) dispatcher.add_handler(CommandHandler("status", status)) conv_handler = ConversationHandler( entry_points=[CommandHandler('auth', auth)], states={ AUTH: [MessageHandler(Filters.text, sms_code)], SMS_CODE: [MessageHandler(Filters.text, fake_name)], FAKE_NAME: [MessageHandler(Filters.text, fake_login)], FAKE_LOGIN: [MessageHandler(Filters.text, final)], }, fallbacks=[CommandHandler('cancel', cancel)], ) dispatcher.add_handler(conv_handler) dispatcher.add_handler(MessageHandler(Filters.regex('^(\/kill_.+)$'), kill)) dispatcher.add_handler(MessageHandler(Filters.regex('joinclubhouse\.com\/room\/.*$') & ~Filters.command, room_msg)) dispatcher.add_handler( MessageHandler(Filters.regex('joinclubhouse\.com\/event\/.*$') & ~Filters.command, event_msg)) dispatcher.add_error_handler(error) updater.start_polling() updater.idle() if __name__ == '__main__': AUTH, SMS_CODE, FAKE_NAME, FAKE_LOGIN = range(4) empty_client = Clubhouse() main()
sleep(15) except: logger.critical('process_queue has broken') print(traceback.format_exc()) sleep(30) if __name__ == "__main__": logger.info('Started cron!') config = configparser.ConfigParser() config.read('settings.ini') TOKEN = config['Telegram']['token'] client = Clubhouse( user_id=config['Clubhouse']['user_id'], user_token=config['Clubhouse']['user_token'], user_device=config['Clubhouse']['user_device'] ) threading.Thread(target=process_audiofiles, args=()).start() logger.info('Started process_audiofiles') threading.Thread(target=process_queue, args=()).start() logger.info('Started process_queue') threading.Thread(target=process_token, args=()).start() logger.info('Started process_token')