This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.py
76 lines (58 loc) · 1.79 KB
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import json
from random import randint
def get_channel():
with open("Stock.json", "r+") as file:
data = json.load(file)
return data['channel']
def add_channel(id):
with open("Stock.json", "r+") as file:
data = json.load(file)
if not id in data['channel']:
data['channel'].append(id)
file.seek(0)
json.dump(data, file, indent=4)
else:
return True
def _tclient():
with open("Stock.json", "r+") as file:
data = json.load(file)
return data['bot_token']
def add_people(user: int):
with open("Stock.json", "r+") as file:
data = json.load(file)
if not user in data['data']['user']:
data['data']['user'].append(user)
file.seek(0)
json.dump(data, file, indent=4)
else:
return True
def get_people():
with open("Stock.json", "r+") as file:
data = json.load(file)
return data['data']['user']
def remove_people(user):
with open('Stock.json', 'r+') as files:
data = json.load(files)
with open('Stock.json', 'w') as file:
x = data['data']['user']
if user in x:
x.remove(user)
data['data']['user'] = x
# file.seek(0)
json.dump(data, file, indent=4)
def add_token(token):
identifiant = randint(10000, 1000000000)
with open("Stock.json", "r+") as file:
data = json.load(file)
data['token'][identifiant] = token
file.seek(0)
json.dump(data, file, indent=4)
return identifiant
def get_id():
with open("Stock.json", "r+") as file:
data = json.load(file)
return data['token']
def id_to_token(id):
with open("Stock.json", "r+") as file:
data = json.load(file)
return data['token'][id]