add support to modify config

This commit is contained in:
2021-01-09 11:15:19 +08:00
parent a7d232a06b
commit c56595e9ba
3 changed files with 114 additions and 3 deletions

View File

@@ -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: