mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
fix抽卡记录导出
This commit is contained in:
parent
60a665362a
commit
da334ddda2
@ -53,16 +53,19 @@ async def ckjl(bot: Bot, event: Union[MessageEvent, GroupMessageEvent], msg: Mes
|
|||||||
|
|
||||||
@gacha_log_update.handle()
|
@gacha_log_update.handle()
|
||||||
async def update_ckjl(event: MessageEvent, msg: Message = CommandArg()):
|
async def update_ckjl(event: MessageEvent, msg: Message = CommandArg()):
|
||||||
|
url = None
|
||||||
|
if msg:
|
||||||
|
msg = str(msg)
|
||||||
|
match = re.search(r'(https://webstatic.mihoyo.com/.*#/log)', msg)
|
||||||
|
if match:
|
||||||
|
url = match.group(1)
|
||||||
|
msg = msg.replace(url, '')
|
||||||
uid, msg, user_id, use_cache = await get_uid_in_msg(event, msg)
|
uid, msg, user_id, use_cache = await get_uid_in_msg(event, msg)
|
||||||
if not uid:
|
if not uid:
|
||||||
await gacha_log_update.finish('请把uid给派蒙哦,比如获取抽卡记录100000001 链接', at_sender=True)
|
await gacha_log_update.finish('请把uid给派蒙哦,比如获取抽卡记录100000001 链接', at_sender=True)
|
||||||
if msg:
|
if msg and not url:
|
||||||
match = re.search(r'(https://webstatic.mihoyo.com/.*#/log)', msg)
|
|
||||||
if match:
|
|
||||||
url = str(match.group(1))
|
|
||||||
else:
|
|
||||||
await gacha_log_update.finish('你这个抽卡链接不对哦,应该是以https://开头、#/log结尾的!', at_sender=True)
|
await gacha_log_update.finish('你这个抽卡链接不对哦,应该是以https://开头、#/log结尾的!', at_sender=True)
|
||||||
else:
|
if not msg and not url:
|
||||||
with open(os.path.join(data_path, 'user_gacha_log.json'), 'r', encoding="utf-8") as f:
|
with open(os.path.join(data_path, 'user_gacha_log.json'), 'r', encoding="utf-8") as f:
|
||||||
user_data = json.load(f)
|
user_data = json.load(f)
|
||||||
if user_id in user_data and uid in user_data[user_id]:
|
if user_id in user_data and uid in user_data[user_id]:
|
||||||
|
@ -32,14 +32,12 @@ async def checkApi(url):
|
|||||||
try:
|
try:
|
||||||
async with ClientSession() as session:
|
async with ClientSession() as session:
|
||||||
r = await session.get(url)
|
r = await session.get(url)
|
||||||
s = (await r.read()).decode("utf-8")
|
j = await r.json()
|
||||||
j = json.loads(s)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# print("API请求解析出错:\n", traceback.format_exc())
|
|
||||||
return f'API请求解析出错:{e}'
|
return f'API请求解析出错:{e}'
|
||||||
|
|
||||||
if not j["data"]:
|
if not j["data"]:
|
||||||
if j["message"] == "authkey valid error":
|
if j["message"] == "authkey error":
|
||||||
return "authkey错误,请重新获取链接给派蒙!"
|
return "authkey错误,请重新获取链接给派蒙!"
|
||||||
elif j["message"] == "authkey timeout":
|
elif j["message"] == "authkey timeout":
|
||||||
return "authkey已过期,请重新获取链接给派蒙!"
|
return "authkey已过期,请重新获取链接给派蒙!"
|
||||||
|
@ -18,8 +18,7 @@ async def getGachaLogs(url, gachaTypeId):
|
|||||||
api = getApi(url, gachaTypeId, size, page, end_id)
|
api = getApi(url, gachaTypeId, size, page, end_id)
|
||||||
async with ClientSession() as session:
|
async with ClientSession() as session:
|
||||||
r = await session.get(api)
|
r = await session.get(api)
|
||||||
s = (await r.read()).decode("utf-8")
|
j = await r.json()
|
||||||
j = json.loads(s)
|
|
||||||
gacha = j["data"]["list"]
|
gacha = j["data"]["list"]
|
||||||
if not len(gacha):
|
if not len(gacha):
|
||||||
break
|
break
|
||||||
@ -53,7 +52,6 @@ def mergeDataFunc(localData, gachaData):
|
|||||||
if flaglist[i] == 0:
|
if flaglist[i] == 0:
|
||||||
gachaGet = bannerGet[i]
|
gachaGet = bannerGet[i]
|
||||||
tempData.insert(0, gachaGet)
|
tempData.insert(0, gachaGet)
|
||||||
# print("追加", len(tempData), "条记录", flush=True)
|
|
||||||
for i in tempData:
|
for i in tempData:
|
||||||
localData["gachaLog"][banner].insert(0, i)
|
localData["gachaLog"][banner].insert(0, i)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ chat_lmt = FreqLimiter2(60)
|
|||||||
|
|
||||||
|
|
||||||
def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, responses):
|
def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, responses):
|
||||||
hammer = on_regex(pattern, priority=14, temp=True)
|
hammer = on_regex(pattern, priority=10)
|
||||||
|
|
||||||
@hammer.handle()
|
@hammer.handle()
|
||||||
async def handler(event: GroupMessageEvent):
|
async def handler(event: GroupMessageEvent):
|
||||||
|
Loading…
Reference in New Issue
Block a user