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')