add support to modify config
This commit is contained in:
19
database.py
19
database.py
@@ -202,6 +202,7 @@ PRIMARY KEY (hash)
|
||||
try:
|
||||
self._db.execute(
|
||||
f"DELETE FROM chatList WHERE chatId={chatId} AND id='{id}'")
|
||||
self._db.commit()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
@@ -235,6 +236,24 @@ PRIMARY KEY (hash)
|
||||
except:
|
||||
return False
|
||||
|
||||
def updateChatConfig(self, chatEntry: ChatEntry) -> bool:
|
||||
with self._value_lock:
|
||||
try:
|
||||
cur = self._db.execute(
|
||||
f"SELECT * FROM chatList WHERE chatId={chatEntry.chatId} AND id='{chatEntry.id}'")
|
||||
has_data = False
|
||||
for i in cur: # pylint: disable=unused-variable
|
||||
has_data = True
|
||||
break
|
||||
if not has_data:
|
||||
return False
|
||||
self._db.execute(
|
||||
f"UPDATE chatList SET config='{dealtext(chatEntry.config.toJson())}' WHERE chatId={chatEntry.chatId} AND id='{chatEntry.id}'")
|
||||
self._db.commit()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def updateRSS(self, title: str, url: str, lastupdatetime: int, hashEntries: HashEntries, ttl: int = None):
|
||||
with self._value_lock:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user