forked from SAGIRI-kawaii/saya_plugins_collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
27 lines (23 loc) · 857 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from .Sqlite3Manager import Sqlite3Manager
async def get_group_switch(group_id: int) -> bool:
conn = Sqlite3Manager.get_instance().get_conn()
sql = f"SELECT switch FROM setting WHERE groupId={group_id}"
print(sql)
cursor = conn.cursor()
cursor.execute(sql)
if result := cursor.fetchall():
cursor.close()
print(result[0][0])
return True if result[0][0] else False
sql = f"INSERT INTO setting (groupId, switch) VALUES (?, ?)"
cursor.execute(sql, (group_id, 1))
conn.commit()
cursor.close()
return True
async def set_group_switch(group_id: int, new_status: int) -> None:
conn = Sqlite3Manager.get_instance().get_conn()
cursor = conn.cursor()
sql = f"UPDATE setting SET switch={new_status} WHERE groupId={group_id}"
cursor.execute(sql)
conn.commit()
cursor.close()