From aa24d1dc47103c1ad3bb3f29cd23229f289c68d7 Mon Sep 17 00:00:00 2001 From: wangyu Date: Tue, 28 Mar 2023 14:17:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E5=88=87=E6=8D=A2UID]=20?= =?UTF-8?q?=E6=8C=87=E4=BB=A4,=20=E7=BB=B4=E6=8A=A4=E5=A4=9A=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E6=83=85=E5=86=B5,=20=E4=BB=8E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=9A=84Cookie=E6=9F=A5=E6=89=BEUID=E5=B9=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2=E4=B8=8B=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=88=B0LastQuery=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/plugins/Paimon_Bind/__init__.py | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/LittlePaimon/plugins/Paimon_Bind/__init__.py b/LittlePaimon/plugins/Paimon_Bind/__init__.py index a049da9..ae4be88 100644 --- a/LittlePaimon/plugins/Paimon_Bind/__init__.py +++ b/LittlePaimon/plugins/Paimon_Bind/__init__.py @@ -78,7 +78,33 @@ refresh_ck = on_command('刷新ck', aliases={'刷新cookie'}, priority=1, block= 'pm_usage': '刷新ck', 'pm_priority': 7 }) +ysch = on_command('ysch', aliases={'原神切换', '切换uid'}, priority=1, block=True, state={ + 'pm_name': 'ysch', + 'pm_description': '切换绑定Cookie的其他UID', + 'pm_usage': 'ysch', + 'pm_priority': 1 +}) +@ysch.handle() +async def _(event: MessageEvent, msg: Message = CommandArg()): + user_id = event.user_id + cookie_list = await PrivateCookie.filter(user_id=event.user_id) + cache_uid = await LastQuery.get_or_none(user_id=user_id) + + if not cookie_list: + ysch.finish(f'你还没有绑定Cookie,如需绑定cookie可看教程:\ndocs.qq.com/doc/DQ3JLWk1vQVllZ2Z1') + + uids = [i.uid for i in cookie_list] + current_uid = uids[0] + if len(cookie_list)>1 and cache_uid and (cache_uid.uid in uids): + current_uid = uids[0] + for idx,uid in enumerate(uids): + if uid == cache_uid.uid: + current_uid = uids[(idx+1)%len(uids)] + break + await LastQuery.update_or_create(user_id=str(event.user_id), + defaults={'uid': current_uid, 'last_time': datetime.datetime.now()}) + ysch.finish(f'当前UID切换为:{current_uid}\n当前绑定的UID列表为[{",".join(uids)}] ') @ysb.handle() async def _(event: MessageEvent, msg: Message = CommandArg()):