Dateien hochladen nach „server“
parent
14cb5e1584
commit
2a6aeb1bbe
|
@ -3,6 +3,7 @@ import random
|
||||||
import string
|
import string
|
||||||
import ast
|
import ast
|
||||||
import copy
|
import copy
|
||||||
|
import time
|
||||||
|
|
||||||
if not os.path.exists("PM server/acc's"):
|
if not os.path.exists("PM server/acc's"):
|
||||||
os.mkdir("PM server")
|
os.mkdir("PM server")
|
||||||
|
@ -23,6 +24,7 @@ else:
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
currentsessionids = {}
|
currentsessionids = {}
|
||||||
|
sessiontime = {}
|
||||||
|
|
||||||
def updatefiles():
|
def updatefiles():
|
||||||
global accounts
|
global accounts
|
||||||
|
@ -56,15 +58,17 @@ def GET(args, ressources=None):
|
||||||
if function == "getsessionid":
|
if function == "getsessionid":
|
||||||
name = args["name"]
|
name = args["name"]
|
||||||
password = args["pass"]
|
password = args["pass"]
|
||||||
for i in currentsessionids:
|
for i in currentsessionids.copy():
|
||||||
if currentsessionids[i] == name:
|
if currentsessionids[i] == name:
|
||||||
del currentsessionids[i]
|
del currentsessionids[i]
|
||||||
|
del sessiontime[i]
|
||||||
if name in accounts:
|
if name in accounts:
|
||||||
if accounts[name]["pass"] == password:
|
if accounts[name]["pass"] == password:
|
||||||
temp = " "
|
temp = " "
|
||||||
for i in range(1,20):
|
for i in range(1,20):
|
||||||
temp = temp + random.choice(list(string.ascii_letters+string.digits))
|
temp = temp + random.choice(list(string.ascii_letters+string.digits))
|
||||||
currentsessionids[temp] = name
|
currentsessionids[temp] = name
|
||||||
|
sessiontime[temp] = time.time()
|
||||||
return temp
|
return temp
|
||||||
else:
|
else:
|
||||||
return "wrong password"
|
return "wrong password"
|
||||||
|
@ -80,6 +84,7 @@ def GET(args, ressources=None):
|
||||||
for i in range(1,20):
|
for i in range(1,20):
|
||||||
temp = temp + random.choice(list(string.ascii_letters+string.digits))
|
temp = temp + random.choice(list(string.ascii_letters+string.digits))
|
||||||
currentsessionids[temp] = name
|
currentsessionids[temp] = name
|
||||||
|
sessiontime[temp] = time.time()
|
||||||
return temp
|
return temp
|
||||||
else:
|
else:
|
||||||
return "name already used!"
|
return "name already used!"
|
||||||
|
@ -87,12 +92,20 @@ def GET(args, ressources=None):
|
||||||
updatefiles()
|
updatefiles()
|
||||||
sessionid = args["sessionid"]
|
sessionid = args["sessionid"]
|
||||||
if sessionid in currentsessionids:
|
if sessionid in currentsessionids:
|
||||||
name = currentsessionids[sessionid]
|
lasttime = sessiontime[sessionid]
|
||||||
temp = []
|
temp = time.time() - lasttime
|
||||||
for i in conversations:
|
if not temp > 60:
|
||||||
if name in i.split("&<splitedaccountname>&"):
|
sessiontime[sessionid] = time.time()
|
||||||
temp.append({"speakers": i, "conversation": copy.deepcopy(conversations[i])})
|
name = currentsessionids[sessionid]
|
||||||
return temp
|
temp = []
|
||||||
|
for i in conversations:
|
||||||
|
if name in i.split("<splitedaccountname>"):
|
||||||
|
temp.append({"speakers": i, "conversation": copy.deepcopy(conversations[i])})
|
||||||
|
return temp
|
||||||
|
else:
|
||||||
|
currentsessionids.pop(sessionid)
|
||||||
|
sessiontime.pop(sessionid)
|
||||||
|
return "sessionid ran out"
|
||||||
|
|
||||||
def PATCH(args, ressources=None):
|
def PATCH(args, ressources=None):
|
||||||
if args["targetfunction"] == "send":
|
if args["targetfunction"] == "send":
|
||||||
|
@ -110,5 +123,5 @@ def PATCH(args, ressources=None):
|
||||||
name = currentsessionids[sessionid]
|
name = currentsessionids[sessionid]
|
||||||
target = args["target"]
|
target = args["target"]
|
||||||
if target in accounts:
|
if target in accounts:
|
||||||
conversations[name+"&<splitedaccountname>&"+target] = ""
|
conversations[name+"<splitedaccountname>"+target] = ""
|
||||||
saveconversations(conversations)
|
saveconversations(conversations)
|
||||||
|
|
Loading…
Reference in New Issue