Skip to content

Commit

Permalink
Merge pull request #1014 from xiayingLIULI/main
Browse files Browse the repository at this point in the history
 对米游社cookie进行判断,整合米游社签到信息
  • Loading branch information
HibiKier authored Aug 22, 2022
2 parents 8697670 + 09ce812 commit 34da04b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions plugins/genshin/query_user/bind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ async def _(event: MessageEvent, cmd: Tuple[str, ...] = Command(), arg: Message
print(cookie)
cookie_json = json.loads(cookie)
print(cookie_json)
if 'login_ticket' not in cookie_json:
await bind.finish("请发送正确完整的cookie!")
login_ticket = cookie_json['login_ticket']
# try:
res = await AsyncHttpx.get(url=bbs_Cookie_url.format(login_ticket))
Expand Down
6 changes: 4 additions & 2 deletions plugins/genshin/query_user/genshin_sign/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ async def _(event: MessageEvent, cmd: Tuple[str, ...] = Command()):
uid = await Genshin.get_user_uid(event.user_id)
if cmd == "查看我的cookie":
my_cookie = await Genshin.get_user_cookie(uid, True)
if isinstance(event, GroupMessageEvent):
await genshin_matcher.finish("请私聊查看您的cookie!")
await genshin_matcher.finish("您的cookie为" + my_cookie)
if not uid or not await Genshin.get_user_cookie(uid, True):
await genshin_matcher.finish("请先绑定uid和cookie!")
# if "account_id" not in await Genshin.get_user_cookie(uid, True):
# await genshin_matcher.finish("请更新cookie!")
if cmd == "原神我硬签":
try:
await genshin_matcher.send("正在进行签到...", at_sender=True)
msg = await genshin_sign(uid)
return_data = await mihoyobbs_sign(event.user_id)
await genshin_matcher.send(return_data)
logger.info(
f"(USER {event.user_id}, "
f"GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) UID:{uid} 原神签到"
Expand All @@ -70,7 +72,7 @@ async def _(event: MessageEvent, cmd: Tuple[str, ...] = Command()):
await u.clear_sign_time(uid)
next_date = await Genshin.random_sign_time(uid)
add_job(event.user_id, uid, next_date)
msg += f"\n因开启自动签到\n下一次签到时间为:{next_date.replace(microsecond=0)}"
msg += f"\n{return_data}\n因开启自动签到\n下一次签到时间为:{next_date.replace(microsecond=0)}"
except Exception as e:
msg = "原神签到失败..请尝试检查cookie或报告至管理员!"
logger.info(
Expand Down
8 changes: 5 additions & 3 deletions plugins/genshin/query_user/mihoyobbs_sign/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@

@mihoyobbs_matcher.handle()
async def _(event: MessageEvent, cmd: Tuple[str, ...] = Command()):
await mihoyobbs_matcher.send("提交米游社签到申请")
await mihoyobbs_matcher.send("提交米游社签到申请", at_sender=True)
return_data = await mihoyobbs_sign(event.user_id)
if return_data:
await mihoyobbs_matcher.finish(return_data)
await mihoyobbs_matcher.finish(return_data, at_sender=True)
else:
await mihoyobbs_matcher.finish("米游社签到失败,请查看控制台输出")
await mihoyobbs_matcher.finish("米游社签到失败,请查看控制台输出", at_sender=True)


async def mihoyobbs_sign(user_id):
uid = await Genshin.get_user_uid(user_id)
if not uid or not await Genshin.get_user_cookie(uid, True):
await mihoyobbs_matcher.finish("请先绑定uid和cookie!", at_sender=True)
stuid = await Genshin.get_stuid(uid)
stoken = await Genshin.get_stoken(uid)
cookie = await Genshin.get_user_cookie(uid)
Expand Down

0 comments on commit 34da04b

Please sign in to comment.