Update app.py
Browse files
app.py
CHANGED
@@ -105,7 +105,7 @@ def save_data_to_webdav():
|
|
105 |
response = requests.put(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
106 |
data=json_data,
|
107 |
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD),
|
108 |
-
timeout=30)
|
109 |
|
110 |
if response.status_code in [200, 201, 204]:
|
111 |
print(f"数据已成功保存到WebDAV: {datetime.now()}")
|
@@ -121,7 +121,7 @@ def load_data_from_webdav():
|
|
121 |
try:
|
122 |
response = requests.get(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
123 |
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD),
|
124 |
-
timeout=30)
|
125 |
|
126 |
if response.status_code == 200:
|
127 |
data = json.loads(response.text)
|
@@ -144,13 +144,11 @@ def load_data_from_webdav():
|
|
144 |
def periodic_save():
|
145 |
print("定期保存线程已启动")
|
146 |
while True:
|
147 |
-
time.sleep(
|
148 |
save_data_to_webdav()
|
149 |
|
150 |
-
# 在程序启动时加载数据
|
151 |
load_data_from_webdav()
|
152 |
|
153 |
-
# 启动定期保存的线程
|
154 |
save_thread = threading.Thread(target=periodic_save)
|
155 |
save_thread.daemon = True
|
156 |
save_thread.start()
|
@@ -232,7 +230,6 @@ async def handleTelegramUpdate(update):
|
|
232 |
else:
|
233 |
GROUP_INFO[chatId]['last_active'] = datetime.now()
|
234 |
|
235 |
-
|
236 |
if not userMessage:
|
237 |
return
|
238 |
|
|
|
105 |
response = requests.put(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
106 |
data=json_data,
|
107 |
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD),
|
108 |
+
timeout=30)
|
109 |
|
110 |
if response.status_code in [200, 201, 204]:
|
111 |
print(f"数据已成功保存到WebDAV: {datetime.now()}")
|
|
|
121 |
try:
|
122 |
response = requests.get(f"{WEBDAV_URL}/tg_bot/bot_data.json",
|
123 |
auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD),
|
124 |
+
timeout=30)
|
125 |
|
126 |
if response.status_code == 200:
|
127 |
data = json.loads(response.text)
|
|
|
144 |
def periodic_save():
|
145 |
print("定期保存线程已启动")
|
146 |
while True:
|
147 |
+
time.sleep(60)
|
148 |
save_data_to_webdav()
|
149 |
|
|
|
150 |
load_data_from_webdav()
|
151 |
|
|
|
152 |
save_thread = threading.Thread(target=periodic_save)
|
153 |
save_thread.daemon = True
|
154 |
save_thread.start()
|
|
|
230 |
else:
|
231 |
GROUP_INFO[chatId]['last_active'] = datetime.now()
|
232 |
|
|
|
233 |
if not userMessage:
|
234 |
return
|
235 |
|