From d72c33b680b25d353f5cdb4f77fd3429e22cb73b Mon Sep 17 00:00:00 2001 From: Andrew Tsegaye Date: Wed, 26 Apr 2023 18:12:33 -0700 Subject: new changes --- quora/mail.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'quora') diff --git a/quora/mail.py b/quora/mail.py index c4707860..e6ce96c2 100644 --- a/quora/mail.py +++ b/quora/mail.py @@ -38,7 +38,7 @@ class Emailnator: return self.email def get_message(self): - print("waiting for code...") + print("Waiting for message...") while True: sleep(2) @@ -49,6 +49,7 @@ class Emailnator: mail_token = loads(mail_token.text)["messageData"] if len(mail_token) == 2: + print("Message received!") print(mail_token[1]["messageID"]) break @@ -63,4 +64,19 @@ class Emailnator: return mail_context.text def get_verification_code(self): - return findall(r';">(\d{6,7})', self.get_message())[0] + message = self.get_message() + code = findall(r';">(\d{6,7})', message)[0] + print(f"Verification code: {code}") + return code + + def clear_inbox(self): + print("Clearing inbox...") + self.client.post( + "https://www.emailnator.com/delete-all", + json={"email": self.email}, + ) + print("Inbox cleared!") + + def __del__(self): + if self.email: + self.clear_inbox() -- cgit v1.2.3 From f1594cfddecf2bd47a25d54852834b392eaa4efd Mon Sep 17 00:00:00 2001 From: Aymane Hrouch Date: Thu, 27 Apr 2023 15:43:59 +0100 Subject: Reformat code using PyCharm --- quora/__init__.py | 56 ++++++++++++++++++++++++------------------------- quora/api.py | 62 +++++++++++++++++++++++++++---------------------------- 2 files changed, 59 insertions(+), 59 deletions(-) (limited to 'quora') diff --git a/quora/__init__.py b/quora/__init__.py index d0ed302f..cd5ec8f9 100644 --- a/quora/__init__.py +++ b/quora/__init__.py @@ -116,11 +116,11 @@ class ModelResponse: class Model: @staticmethod def create( - token: str, - model: str = 'gpt-3.5-turbo', # claude-instant - system_prompt: str = 'You are ChatGPT a large language model developed by Openai. Answer as consisely as possible', - description: str = 'gpt-3.5 language model from openai, skidded by poe.com', - handle: str = None, + token: str, + model: str = 'gpt-3.5-turbo', # claude-instant + system_prompt: str = 'You are ChatGPT a large language model developed by Openai. Answer as consisely as possible', + description: str = 'gpt-3.5 language model from openai, skidded by poe.com', + handle: str = None, ) -> ModelResponse: models = { 'gpt-3.5-turbo': 'chinchilla', @@ -202,9 +202,9 @@ class Model: class Account: @staticmethod def create( - proxy: Optional[str] = None, - logging: bool = False, - enable_bot_creation: bool = False, + proxy: Optional[str] = None, + logging: bool = False, + enable_bot_creation: bool = False, ): client = TLS(client_identifier='chrome110') client.proxies = {'http': f'http://{proxy}', 'https': f'http://{proxy}'} if proxy else None @@ -309,10 +309,10 @@ class Account: class StreamingCompletion: @staticmethod def create( - model: str = 'gpt-4', - custom_model: bool = None, - prompt: str = 'hello world', - token: str = '', + model: str = 'gpt-4', + custom_model: bool = None, + prompt: str = 'hello world', + token: str = '', ): _model = MODELS[model] if not custom_model else custom_model @@ -344,10 +344,10 @@ class StreamingCompletion: class Completion: def create( - model: str = 'gpt-4', - custom_model: str = None, - prompt: str = 'hello world', - token: str = '', + model: str = 'gpt-4', + custom_model: str = None, + prompt: str = 'hello world', + token: str = '', ): models = { 'sage': 'capybara', @@ -389,12 +389,12 @@ class Completion: class Poe: def __init__( - self, - model: str = 'ChatGPT', - driver: str = 'firefox', - download_driver: bool = False, - driver_path: Optional[str] = None, - cookie_path: str = './quora/cookie.json', + self, + model: str = 'ChatGPT', + driver: str = 'firefox', + download_driver: bool = False, + driver_path: Optional[str] = None, + cookie_path: str = './quora/cookie.json', ): # validating the model if model and model not in MODELS: @@ -473,12 +473,12 @@ class Poe: return response def create_bot( - self, - name: str, - /, - prompt: str = '', - base_model: str = 'ChatGPT', - description: str = '', + self, + name: str, + /, + prompt: str = '', + base_model: str = 'ChatGPT', + description: str = '', ) -> None: if base_model not in MODELS: raise RuntimeError('Sorry, the base_model you provided does not exist. Please check and try again.') diff --git a/quora/api.py b/quora/api.py index 42814f2c..697f6663 100644 --- a/quora/api.py +++ b/quora/api.py @@ -384,7 +384,7 @@ class Client: continue # update info about response - message["text_new"] = message["text"][len(last_text) :] + message["text_new"] = message["text"][len(last_text):] last_text = message["text"] message_id = message["messageId"] @@ -456,21 +456,21 @@ class Client: logger.info(f"No more messages left to delete.") def create_bot( - self, - handle, - prompt="", - base_model="chinchilla", - description="", - intro_message="", - api_key=None, - api_bot=False, - api_url=None, - prompt_public=True, - pfp_url=None, - linkification=False, - markdown_rendering=True, - suggested_replies=False, - private=False, + self, + handle, + prompt="", + base_model="chinchilla", + description="", + intro_message="", + api_key=None, + api_bot=False, + api_url=None, + prompt_public=True, + pfp_url=None, + linkification=False, + markdown_rendering=True, + suggested_replies=False, + private=False, ): result = self.send_query( "PoeBotCreateMutation", @@ -499,21 +499,21 @@ class Client: return data def edit_bot( - self, - bot_id, - handle, - prompt="", - base_model="chinchilla", - description="", - intro_message="", - api_key=None, - api_url=None, - private=False, - prompt_public=True, - pfp_url=None, - linkification=False, - markdown_rendering=True, - suggested_replies=False, + self, + bot_id, + handle, + prompt="", + base_model="chinchilla", + description="", + intro_message="", + api_key=None, + api_url=None, + private=False, + prompt_public=True, + pfp_url=None, + linkification=False, + markdown_rendering=True, + suggested_replies=False, ): result = self.send_query( "PoeBotEditMutation", -- cgit v1.2.3