Beispiel #1
0
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()
Beispiel #2
0
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
Beispiel #3
0
class FollowersIDScraper:
    def __init__(self):
        self.clubhouse = Clubhouse()

    def login(self):
        phone_num = input('Enter your phone number (for example +1 2345): ')
        self.clubhouse.start_phone_number_auth(phone_num)
        # self.clubhouse.call_phone_number_auth(phone_num)
        verification_code = input('Enter the code you received: ')
        authorization_json = self.clubhouse.complete_phone_number_auth(phone_num, verification_code)
        user_id = str(authorization_json['user_profile']['user_id'])
        user_token = str(authorization_json['auth_token'])
        self.clubhouse.__init__(user_id, user_token)

    def get_followers(self, account_id):
        followers = self.clubhouse.get_followers(account_id, page_size=50, page=1)
        total_followers = followers['count']
        followers = [follower for follower in followers['users']]
        for page_num in range(2, total_followers // 50 + 1):
            followers.extend([follower for follower in
                              self.clubhouse.get_followers(account_id, page_size=50, page=page_num)['users']])
        return [follower['user_id'] for follower in followers]

    def get_user_id(self, username):
        return self.clubhouse.search_users(username)['users'][0]['user_id']

    def scrape_followers(self, username, csv_filename='output.csv', json_filename='output.json'):
        account_id = self.get_user_id(username)
        followers = self.get_followers(account_id)
        with open(csv_filename, 'a+') as csv_file:
            writer = csv.writer(csv_file)
            for follower in followers:
                writer.writerow([follower])
        print(f'Finished adding followers to {csv_filename}')

        with open(json_filename, 'a+') as json_file:
            json.dump(followers, json_file)
        print(f'Finished adding followers to {json_filename}')
Beispiel #4
0
from clubhouse.clubhouse import Clubhouse

if __name__ == "__main__":
    clubhouse = Clubhouse()

    #hello message
    print("clubhouse-tools / invite \n©2021 by Nikita Nikonov \n ")

    #user enters tel
    phone_number = input("Enter your phone number to login into Clubhouse: ")

    #send verification code
    clubhouse.start_phone_number_auth(phone_number)
    print("Verification code sent")

    #user enters sms verification code to login
    verification_code = input("Enter it: ")
    clubhouse.complete_phone_number_auth(phone_number, verification_code)

    #user enters phone number of user he wants to invite
    phone_number = input("Enter phone number of user you want to invite: ")
    name = input("Enter name of user you want to invite: ")
    clubhouse.invite_to_app(name, phone_number, "Invited from clubhouse-tools/invite")
Beispiel #5
0
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()

    loop = asyncio.get_event_loop()

    ch = Clubhouse()

    while True:
        data = await websocket.receive_json()
        logger.info(f'Receive data: {data}')
        try:
            id_, method, params, _ = data['id'], \
                data['method'], data['params'], data['jsonrpc']
        except KeyError:
            await websocket.send_json({
                'id': data.get('id', 0),
                'result': None,
                'error': {
                    'message': 'Invalid rpc 2.0 structure',
                    'code': -32602
                }
            })
            continue

        try:
            logger.info(f'Got method "{method}" with params "{params}"')
            if method == 'authenticate':
                params[1] = str(params[1] or '').replace('Token', '').strip()
                ch = Clubhouse(*params)
                # just test authorization
                await websocket.send_json({
                    'id': 'auth',
                    'result': get_creds(ch),
                    'error': None
                })
                logger.info(f'Updating creds for user #{params[0]}')
                continue
            response = await loop.run_in_executor(
                None, lambda: getattr(ch, method)(*params))
        except AttributeError as e:
            logger.exception(e)
            await websocket.send_json({
                'id': id_,
                'result': None,
                'error': {
                    'message': 'Method not found',
                    'code': -32601
                }
            })
            continue
        except TypeError as e:
            logger.exception(e)
            await websocket.send_json({
                'id': id_,
                'result': None,
                'error': {
                    'message': e.args[0],
                    'code': -1
                }
            })
            continue
        except Exception as e:
            logger.exception(e)
            if 'Not Authenticated' in e.args[0]:
                ch = Clubhouse()
                await websocket.send_json({
                    'id': id_,
                    'result': None,
                    'error': {
                        'message': 'Not Authenticated',
                        'code': -32600
                    }
                })
            else:
                await websocket.send_json({
                    'id': id_,
                    'result': None,
                    'error': {
                        'message': 'Internal server error',
                        'code': -32000
                    }
                })
            continue

        await websocket.send_json({
            'id': id_,
            'result': response,
            'error': None
        })

        if method == 'complete_phone_number_auth' and 'auth_token' in response:
            clubhouse_creds = {
                'user_id': response['user_profile']['user_id'],
                'user_token': response['auth_token'],
                'user_device': ch.HEADERS['CH-DeviceId'],
            }
            ch = Clubhouse(**clubhouse_creds)
            logger.info(
                f'Updating creds for user #{clubhouse_creds["user_id"]}')
            await websocket.send_json({
                'id': 'auth',
                'result': clubhouse_creds,
                'error': None
            })
Beispiel #6
0
 def __init__(self):
     self.clubhouse = Clubhouse()