From 365f5eb7e3bdffb910399554d0fcf4acec1c8181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wuyi=E6=97=A0=E7=96=91?= <444835641@qq.com> Date: Wed, 2 Feb 2022 11:01:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=85=A8=E9=83=A8Cookies=E7=8E=B0=E5=9C=A8=E4=BC=9A=E7=A7=81?= =?UTF-8?q?=E8=81=8A=E5=B7=B2=E5=A4=B1=E6=95=88CK=E7=9A=84QQ=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E6=8F=90=E9=86=92ck=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 9 +++++++-- getDB.py | 13 +++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index 7c32508b..191194f3 100644 --- a/__init__.py +++ b/__init__.py @@ -451,8 +451,13 @@ async def _(bot:HoshinoBot, ev: CQEvent): @sv.on_fullmatch('校验全部Cookies') async def _(bot:HoshinoBot, ev: CQEvent): try: - im = await CheckDB() - await bot.send(ev,im) + raw_mes = await CheckDB() + im = raw_mes[0] + await bot.send(ev,im) + for i in raw_mes[1]: + await bot.send_private_msg(user_id = i[0], + message = "您绑定的Cookies(uid{})已失效,以下功能将会受到影响:\n查看完整信息列表\n查看深渊配队\n自动签到/当前状态/每月统计\n请及时重新绑定Cookies并重新开关相应功能。".format(i[1])) + await asyncio.sleep(3+random.randint(1,3)) except Exception as e: traceback.print_exc() await bot.send(ev,"发生错误 {},请检查后台输出。".format(e)) diff --git a/getDB.py b/getDB.py index 44b32294..ba14431b 100644 --- a/getDB.py +++ b/getDB.py @@ -95,9 +95,10 @@ async def OpenPush(uid,qid,status,mode): async def CheckDB(): str = '' + invalidlist = [] conn = sqlite3.connect('ID_DATA.db') c = conn.cursor() - cursor = c.execute("SELECT UID,Cookies from NewCookiesTable") + cursor = c.execute("SELECT UID,Cookies,QID from NewCookiesTable") c_data = cursor.fetchall() for row in c_data: try: @@ -112,15 +113,15 @@ async def CheckDB(): str = str + f"uid{row[0]}/mysid{mysid}的Cookies是正常的!\n" except: str = str + f"uid{row[0]}的Cookies是异常的!已删除该条Cookies!\n" + invalidlist.append([row[2],row[0]]) c.execute("DELETE from NewCookiesTable where UID=?",(row[0],)) - test = c.execute("SELECT count(*) FROM sqlite_master WHERE type='table' AND name = 'CookiesCache'") - if test == 0: - pass - else: + try: c.execute("DELETE from CookiesCache where Cookies=?",(row[1],)) + except: + pass conn.commit() conn.close() - return str + return [str,invalidlist] async def connectDB(userid,uid = None,mys = None): conn = sqlite3.connect('ID_DATA.db')