mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
🚑 mys签到
出现验证码时进行重试
This commit is contained in:
parent
db2aee32a3
commit
c27a4d9c36
@ -497,12 +497,16 @@ async def mys_sign_handler(event: MessageEvent, msg: Message = CommandArg()):
|
|||||||
else:
|
else:
|
||||||
sign_day = sign_info['data']['total_sign_day']
|
sign_day = sign_info['data']['total_sign_day']
|
||||||
sign_action = await sign(uid)
|
sign_action = await sign(uid)
|
||||||
if isinstance(sign_action, str):
|
for _ in range(5):
|
||||||
await mys_sign.finish(sign_action, at_sender=True)
|
if isinstance(sign_action, dict):
|
||||||
else:
|
if sign_action['data']['success'] == 0:
|
||||||
await mys_sign.finish(
|
await mys_sign.finish(
|
||||||
f'签到成功,获得的奖励为:\n{sign_list["data"]["awards"][sign_day]["name"]} * {sign_list["data"]["awards"][sign_day]["cnt"]}',
|
f'签到成功,获得的奖励为:\n{sign_list["data"]["awards"][sign_day]["name"]} * {sign_list["data"]["awards"][sign_day]["cnt"]}',
|
||||||
at_sender=True)
|
at_sender=True)
|
||||||
|
else:
|
||||||
|
await sleep(random.randint(3, 6))
|
||||||
|
else:
|
||||||
|
await mys_sign.finish(sign_action, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@mys_sign_auto.handle()
|
@mys_sign_auto.handle()
|
||||||
@ -660,8 +664,11 @@ async def auto_sign():
|
|||||||
sign_list = await get_sign_list()
|
sign_list = await get_sign_list()
|
||||||
for user_id, uid, remind_id in data:
|
for user_id, uid, remind_id in data:
|
||||||
await sleep(random.randint(20, 35))
|
await sleep(random.randint(20, 35))
|
||||||
|
for _ in range(5):
|
||||||
sign_result = await sign(uid)
|
sign_result = await sign(uid)
|
||||||
if not isinstance(sign_result, str):
|
if isinstance(sign_result, dict):
|
||||||
|
# success为0则说明没有出现验证码,不为0则有验证码,等待5-10秒再重试,重试最多5次
|
||||||
|
if sign_result['data']['success'] == 0:
|
||||||
await sleep(1)
|
await sleep(1)
|
||||||
sign_info = await get_sign_info(uid)
|
sign_info = await get_sign_info(uid)
|
||||||
sign_day = sign_info['data']['total_sign_day'] - 1
|
sign_day = sign_info['data']['total_sign_day'] - 1
|
||||||
@ -671,6 +678,9 @@ async def auto_sign():
|
|||||||
else:
|
else:
|
||||||
ann[remind_id]['成功'].append(
|
ann[remind_id]['成功'].append(
|
||||||
f'.UID{uid}-{sign_list["data"]["awards"][sign_day]["name"]}*{sign_list["data"]["awards"][sign_day]["cnt"]}')
|
f'.UID{uid}-{sign_list["data"]["awards"][sign_day]["name"]}*{sign_list["data"]["awards"][sign_day]["cnt"]}')
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
await sleep(random.randint(5, 10))
|
||||||
else:
|
else:
|
||||||
await delete_auto_sign(user_id, uid)
|
await delete_auto_sign(user_id, uid)
|
||||||
if remind_id.startswith('q'):
|
if remind_id.startswith('q'):
|
||||||
@ -678,6 +688,7 @@ async def auto_sign():
|
|||||||
message=f'你的uid{uid}签到失败,请重新绑定cookie再开启自动签到')
|
message=f'你的uid{uid}签到失败,请重新绑定cookie再开启自动签到')
|
||||||
else:
|
else:
|
||||||
ann[remind_id]['失败'].append(f'.UID{uid}')
|
ann[remind_id]['失败'].append(f'.UID{uid}')
|
||||||
|
break
|
||||||
for group_id, content in ann.items():
|
for group_id, content in ann.items():
|
||||||
group_str = '米游社自动签到结果:\n'
|
group_str = '米游社自动签到结果:\n'
|
||||||
for type, ann_list in content.items():
|
for type, ann_list in content.items():
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
from asyncio import sleep
|
|
||||||
|
|
||||||
from littlepaimon_utils import aiorequests
|
from littlepaimon_utils import aiorequests
|
||||||
|
from nonebot import logger
|
||||||
|
|
||||||
from ..utils.auth_util import get_headers, get_sign_headers, get_use_cookie, get_own_cookie, check_retcode
|
from ..utils.auth_util import get_headers, get_sign_headers, get_use_cookie, get_own_cookie, check_retcode
|
||||||
from ..utils.db_util import get_private_cookie, update_cookie_cache, update_private_cookie
|
from ..utils.db_util import get_private_cookie, update_cookie_cache, update_private_cookie
|
||||||
@ -223,10 +223,8 @@ async def sign(uid):
|
|||||||
'region': server_id
|
'region': server_id
|
||||||
}
|
}
|
||||||
resp = await aiorequests.post(url=url, headers=headers, json=json_data)
|
resp = await aiorequests.post(url=url, headers=headers, json=json_data)
|
||||||
try:
|
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
except:
|
logger.info(f'---UID{uid}的签到状态码为{data["retcode"]},结果为{data["message"]}---')
|
||||||
return resp.read()
|
|
||||||
if await check_retcode(data, cookie, uid):
|
if await check_retcode(data, cookie, uid):
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user