优化:校验全部Cookies现在会私聊已失效CK的QQ账号提醒ck过期

This commit is contained in:
Wuyi无疑 2022-02-02 11:01:14 +08:00
parent 0b3595f9c3
commit 365f5eb7e3
2 changed files with 14 additions and 8 deletions

View File

@ -451,8 +451,13 @@ async def _(bot:HoshinoBot, ev: CQEvent):
@sv.on_fullmatch('校验全部Cookies') @sv.on_fullmatch('校验全部Cookies')
async def _(bot:HoshinoBot, ev: CQEvent): async def _(bot:HoshinoBot, ev: CQEvent):
try: try:
im = await CheckDB() raw_mes = await CheckDB()
await bot.send(ev,im) 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 = "您绑定的Cookiesuid{})已失效,以下功能将会受到影响:\n查看完整信息列表\n查看深渊配队\n自动签到/当前状态/每月统计\n请及时重新绑定Cookies并重新开关相应功能。".format(i[1]))
await asyncio.sleep(3+random.randint(1,3))
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
await bot.send(ev,"发生错误 {},请检查后台输出。".format(e)) await bot.send(ev,"发生错误 {},请检查后台输出。".format(e))

View File

@ -95,9 +95,10 @@ async def OpenPush(uid,qid,status,mode):
async def CheckDB(): async def CheckDB():
str = '' str = ''
invalidlist = []
conn = sqlite3.connect('ID_DATA.db') conn = sqlite3.connect('ID_DATA.db')
c = conn.cursor() c = conn.cursor()
cursor = c.execute("SELECT UID,Cookies from NewCookiesTable") cursor = c.execute("SELECT UID,Cookies,QID from NewCookiesTable")
c_data = cursor.fetchall() c_data = cursor.fetchall()
for row in c_data: for row in c_data:
try: try:
@ -112,15 +113,15 @@ async def CheckDB():
str = str + f"uid{row[0]}/mysid{mysid}的Cookies是正常的\n" str = str + f"uid{row[0]}/mysid{mysid}的Cookies是正常的\n"
except: except:
str = str + f"uid{row[0]}的Cookies是异常的已删除该条Cookies\n" str = str + f"uid{row[0]}的Cookies是异常的已删除该条Cookies\n"
invalidlist.append([row[2],row[0]])
c.execute("DELETE from NewCookiesTable where UID=?",(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'") try:
if test == 0:
pass
else:
c.execute("DELETE from CookiesCache where Cookies=?",(row[1],)) c.execute("DELETE from CookiesCache where Cookies=?",(row[1],))
except:
pass
conn.commit() conn.commit()
conn.close() conn.close()
return str return [str,invalidlist]
async def connectDB(userid,uid = None,mys = None): async def connectDB(userid,uid = None,mys = None):
conn = sqlite3.connect('ID_DATA.db') conn = sqlite3.connect('ID_DATA.db')