mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
修复绑定cookie
This commit is contained in:
parent
80db03614e
commit
5e5c3ba0b0
@ -97,7 +97,7 @@ async def get_monthinfo_data(uid, month, cookie, use_cache=True):
|
|||||||
return await res.json()
|
return await res.json()
|
||||||
|
|
||||||
async def get_bind_game(cookie):
|
async def get_bind_game(cookie):
|
||||||
finduid = re.search(r'account_id=(/d*);', cookie)
|
finduid = re.search(r'account_id=(\d{9})', cookie)
|
||||||
if not finduid:
|
if not finduid:
|
||||||
return None
|
return None
|
||||||
uid = finduid.group(1)
|
uid = finduid.group(1)
|
||||||
|
@ -11,7 +11,9 @@ def get_font(size):
|
|||||||
return ImageFont.truetype(os.path.join(res_path,'msyh.ttc'), size)
|
return ImageFont.truetype(os.path.join(res_path,'msyh.ttc'), size)
|
||||||
|
|
||||||
def get_expl_per(percentage):
|
def get_expl_per(percentage):
|
||||||
if percentage != 1000:
|
if percentage == 0:
|
||||||
|
return '0%'
|
||||||
|
elif percentage != 1000:
|
||||||
p = list(str(percentage))
|
p = list(str(percentage))
|
||||||
p.insert(-1, '.')
|
p.insert(-1, '.')
|
||||||
return ''.join(p) + '%'
|
return ''.join(p) + '%'
|
||||||
|
@ -11,14 +11,15 @@ async def bind(bot,ev):
|
|||||||
cookie = ev.message.extract_plain_text().strip()
|
cookie = ev.message.extract_plain_text().strip()
|
||||||
qq=str(ev.user_id)
|
qq=str(ev.user_id)
|
||||||
if cookie == '':
|
if cookie == '':
|
||||||
res = '''旅行者好呀,你可以直接用ys/ysa等指令附上uid来使用派蒙\n如果想看全部角色信息和实时便笺等功能,要把cookie给派蒙哦\ncookie获取方法:登录网页版米游社,在地址栏粘贴代码:\njavascript:(function(){prompt(document.domain,document.cookie)})();\n复制弹窗出来的字符串(手机要via或chrome浏览器才行)\n然后添加派蒙私聊发送ysb接刚刚复制的字符串,例如:ysb UM_distinctid=17d131d...'''
|
res = '''旅行者好呀,你可以直接用ys/ysa等指令附上uid来使用派蒙\n如果想看全部角色信息和实时便笺等功能,要把cookie给派蒙哦\ncookie获取方法:登录网页版米游社,在地址栏粘贴代码:\njavascript:(function(){prompt(document.domain,document.cookie)})();\n复制弹窗出来的字符串(手机要via或chrome浏览器才行)\n然后添加派蒙私聊发送ysb接刚刚复制的字符串,例如:ysb UM_distinctid=17d131d...\ncookie是账号重要安全信息,请确保机器人持有者可信赖!'''
|
||||||
await bot.send(ev,res,at_sender=True)
|
await bot.send(ev,res,at_sender=True)
|
||||||
else:
|
else:
|
||||||
cookie_info = await get_bind_game(cookie)
|
cookie_info = await get_bind_game(cookie)
|
||||||
if cookie_info['retcode'] != 0:
|
if not cookie_info or cookie_info['retcode'] != 0:
|
||||||
await bot.send(ev,'这cookie没有用哦,检查一下是不是复制错了或者过期了(试试重新登录米游社再获取)',at_sender=True)
|
msg = f'这cookie没有用哦,检查一下是不是复制错了或者过期了(试试重新登录米游社再获取),错误信息:{cookie_info["message"]}'
|
||||||
if ev.detail_type != 'private':
|
if ev.detail_type != 'private':
|
||||||
await bot.send(ev,'当前是在群聊里绑定,建议旅行者添加派蒙好友私聊绑定!',at_sender=True)
|
msg += '\n当前是在群聊里绑定,建议旅行者添加派蒙好友私聊绑定!'
|
||||||
|
await bot.send(ev,msg,at_sender=True)
|
||||||
else:
|
else:
|
||||||
for data in cookie_info['data']['list']:
|
for data in cookie_info['data']['list']:
|
||||||
if data['game_id'] == 2:
|
if data['game_id'] == 2:
|
||||||
@ -28,9 +29,10 @@ async def bind(bot,ev):
|
|||||||
break
|
break
|
||||||
if uid:
|
if uid:
|
||||||
await bind_cookie(qq,uid,cookie)
|
await bind_cookie(qq,uid,cookie)
|
||||||
await bot.send(ev, f'{nickname}绑定成功啦!使用ys/ysa等指令和派蒙互动吧!',at_sender=True)
|
msg = f'{nickname}绑定成功啦!使用ys/ysa等指令和派蒙互动吧!'
|
||||||
if ev.detail_type != 'private':
|
if ev.detail_type != 'private':
|
||||||
await bot.send(ev,'当前是在群聊里绑定,建议旅行者把cookie撤回哦!',at_sender=True)
|
msg += '\n当前是在群聊里绑定,建议旅行者把cookie撤回哦!'
|
||||||
|
await bot.send(ev,msg,at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('添加公共cookie')
|
@sv.on_prefix('添加公共cookie')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user