Skip to content

Commit

Permalink
fix: unfunctional when manual login
Browse files Browse the repository at this point in the history
  • Loading branch information
lss233 committed Jan 12, 2023
1 parent 8e951c8 commit a92e283
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ OpenAI 配置的信息可参考 [这里](https://github.com/acheong08/ChatGPT/wi
当你使用这种方式登录时,需要在打开的浏览器页面中完成 OpenAI 的登录。
您需要点击页面中的 `Log in` 按钮,我们会自动为您填写 `email`,剩下的需要您自己完成。
我们会自动点击页面中的 `Log in` 按钮、为您填写 `email`,剩下的需要您自己完成。
登录完成后,浏览器会自动退出。
Expand Down
3 changes: 0 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ async def handle_message(target: Union[Friend, Group], session_id: str, message:
except Exception as e:
# 出现故障,刷新 session_token
logger.exception(e)
refresh_task = bot.refresh_session()
if refresh_task: # 这么写主要是因为上游偶尔返回的是一个 promise
await refresh_task
return config.response.error_format.format(exc=e)


Expand Down
14 changes: 12 additions & 2 deletions chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,29 @@ class mChatbot(Chatbot):
def __init__(self, config, conversation_id=None, parent_id=None) -> None:
if not config.get("captcha"):
config["captcha"] = 'manual'

global bot
bot = self
super().__init__(config, conversation_id, parent_id)

def solve_captcha(self, *args, **kwargs) -> str:
if self.twocaptcha_key == 'manual':
return self._solve_captcha_manual(*args, **kwargs)
return super().solve_captcha(*args, **kwargs)

def get_cf_cookies(self) -> None:
logger.info("检测到 cf_clearance 失效,正在尝试重新获取……")
logger.info(" 提示:出现登录页面时无需登录")
logger.info(" 如果程序不断再次重复,请尝试更换 IP")
super().get_cf_cookies()
logger.debug(f"获取到 cf_clearance: {self.cf_clearance}")

def _solve_captcha_manual(self):
class _:
def get(_self, key):
while not self.session_cookie_found:
logger.info("等待中,请在打开的浏览器页面中完成登录……")
sleep(5)
logger.debug(f"获取到 cf_clearance: {self.cf_clearance}")
logger.debug(f"获取到 session_token: {self.session_token}")
raise BlowUpDeliberatelyException()
return _()

Expand Down

0 comments on commit a92e283

Please sign in to comment.