From 2ee97e659b6c24bd92a7bd386fb166035b8c4c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A9=BF=E8=B6=8A=E7=94=B5=E7=BA=BF?= Date: Sun, 7 Aug 2022 22:03:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug=EF=BC=9A=E8=A7=A3=E5=86=B3=E5=A4=9Acq?= =?UTF-8?q?=E7=AB=AF=E4=B8=8B=E7=A7=81=E8=81=8A=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index 09c8f90..f096aaf 100644 --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,6 @@ from json import load, dump import json +import random from nonebot import get_bot, on_command from hoshino import priv from hoshino.typing import NoticeSession, MessageSegment @@ -72,6 +73,7 @@ async def send_jjchelp(bot, ev): async def captchaVerifier(gt, challenge, userid): global acfirst, validating + sid = hoshino.get_self_ids() # 获取bot账号列表 if not acfirst: await captcha_lck.acquire() acfirst = True @@ -79,11 +81,17 @@ async def captchaVerifier(gt, challenge, userid): if acinfo['admin'] == 0: bot.logger.error('captcha is required while admin qq is not set, so the login can\'t continue') else: - url = f"https://help.tencentbot.top/geetest/?captcha_type=1&challenge={challenge}>={gt}&userid={userid}&gs=1" - await bot.send_private_msg( - user_id = acinfo['admin'], - message = f'pcr账号登录需要验证码,请完成以下链接中的验证内容后将第一行validate=后面的内容复制,并用指令/pcrval xxxx将内容发送给机器人完成验证\n验证链接:{url}' - ) + if len(sid) > 0: # 若bot账号数量大于0,则随机选择一个号向管理员QQ发送私聊消息(记得先加bot好友!) + sid = random.choice(sid) + url = f"https://help.tencentbot.top/geetest/?captcha_type=1&challenge={challenge}>={gt}&userid={userid}&gs=1" + try: + await bot.send_private_msg( + self_id = sid, + user_id = acinfo['admin'], + message = f'pcr账号登录需要验证码,请完成以下链接中的验证内容后将第一行validate=后面的内容复制,并用指令/pcrval xxxx将内容发送给机器人完成验证\n验证链接:{url}' + ) + except Exception as e: + hoshino.logger.error(f'向管理员QQ发送私聊验证码消息失败:{type(e)}') validating = True await captcha_lck.acquire() validating = False