add computing connect
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
import json
|
||||
|
||||
|
||||
def load_data():
|
||||
try:
|
||||
with open('users.json', 'r') as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
return {'users': [], 'chats': []}
|
||||
|
||||
|
||||
def save_data(data_type, data_id=None):
|
||||
data = load_data()
|
||||
if data_id is None:
|
||||
if 'static' not in data:
|
||||
data['static'] = {'audio_resive': 0, 'chatGPT': 0}
|
||||
if 'audio_resive' not in data['static']:
|
||||
data['static'][data_type] = 0
|
||||
if 'chatGPT' not in data['static']:
|
||||
data['static']['chatGPT'] = 0
|
||||
data['static'][data_type] += 1
|
||||
with open('users.json', 'w') as f:
|
||||
json.dump(data, f, indent=4)
|
||||
else:
|
||||
if data_id not in data[data_type]:
|
||||
data[data_type].append(data_id)
|
||||
with open('users.json', 'w') as f:
|
||||
json.dump(data, f, indent=4)
|
||||
Reference in New Issue
Block a user