yangtb24 commited on
Commit
a930e30
·
verified ·
1 Parent(s): a626a6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -96,16 +96,21 @@ def save_data_to_webdav():
96
  'USER_SETTINGS': USER_SETTINGS,
97
  'USER_LAST_ACTIVE': {k: v.isoformat() for k, v in USER_LAST_ACTIVE.items()},
98
  'GROUP_ACTIVE_USERS': {k: list(v) for k, v in GROUP_ACTIVE_USERS.items()},
99
- 'GROUP_INFO': {k: {**v, 'last_active': v['last_active'].isoformat()} for k, v in GROUP_INFO.items()},
 
 
 
100
  'BANNED_USERS': {k: v.isoformat() for k, v in BANNED_USERS.items()}
101
  }
102
 
103
  json_data = json.dumps(data)
104
 
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()}")
@@ -144,7 +149,7 @@ def load_data_from_webdav():
144
  def periodic_save():
145
  print("定期保存线程已启动")
146
  while True:
147
- time.sleep(60)
148
  save_data_to_webdav()
149
 
150
  load_data_from_webdav()
 
96
  'USER_SETTINGS': USER_SETTINGS,
97
  'USER_LAST_ACTIVE': {k: v.isoformat() for k, v in USER_LAST_ACTIVE.items()},
98
  'GROUP_ACTIVE_USERS': {k: list(v) for k, v in GROUP_ACTIVE_USERS.items()},
99
+ 'GROUP_INFO': {
100
+ k: {**v, 'last_active': v['last_active'].isoformat()}
101
+ for k, v in GROUP_INFO.items()
102
+ },
103
  'BANNED_USERS': {k: v.isoformat() for k, v in BANNED_USERS.items()}
104
  }
105
 
106
  json_data = json.dumps(data)
107
 
108
+ response = requests.put(
109
+ f"{WEBDAV_URL}/tg_bot/bot_data.json",
110
+ data=json_data,
111
+ auth=HTTPBasicAuth(WEBDAV_USERNAME, WEBDAV_PASSWORD),
112
+ timeout=30
113
+ )
114
 
115
  if response.status_code in [200, 201, 204]:
116
  print(f"数据已成功保存到WebDAV: {datetime.now()}")
 
149
  def periodic_save():
150
  print("定期保存线程已启动")
151
  while True:
152
+ time.sleep(10)
153
  save_data_to_webdav()
154
 
155
  load_data_from_webdav()