-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpendingM.py
33 lines (29 loc) · 856 Bytes
/
pendingM.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
import json
from users import getAllUsers
# get pending messages from pendig_messages.json
async def getPindings():
with open("data/pending_messages.json","r",encoding='utf-8') as f:
ms = json.load(f)
return ms
# set data into pending_messages
async def setDataP(data):
with open("data/pending_messages.json","w") as f:
json.dump(data,f)
# put allUsers.json in pending_messages
async def setPendingM():
users = await getAllUsers()
pendings = {}
for u in users["users"]:
pendings[u[0]] = u[1]
await setDataP(pendings)
# remove from pending
async def removePen(id):
pendings = await getPindings()
if id in pendings:
pendings.pop(id)
await setDataP(pendings)
async def isPending(id):
pendings = await getPindings()
if id in pendings:
return True
return False