added admins and banning
this took more time than i thought it would
This commit is contained in:
@@ -125,19 +125,23 @@ class ServerConnection(BasicServerConnection):
|
||||
async def status(self):
|
||||
return await super().ask({"type": "status"})
|
||||
|
||||
async def __login(self):
|
||||
async def __login(self,logincmd=None):
|
||||
# print("__login")
|
||||
if self.logincmd == None: return {"type": "error", "error": "No credentials found.", "server": False}
|
||||
if logincmd==None: logincmd=self.logincmd
|
||||
if logincmd == None: return {"type": "error", "error": "No credentials found.", "server": False}
|
||||
stat = await self.status()
|
||||
if stat==None: return
|
||||
if stat["type"]=="error" or stat["response"]["login"]==False:
|
||||
return await super().ask(self.logincmd)
|
||||
return await super().ask(logincmd)
|
||||
|
||||
async def login(self,name: str,pwrd: str):
|
||||
res = hashlib.md5(pwrd.encode("utf8"))
|
||||
psum = res.hexdigest()
|
||||
self.logincmd = {"type": "login", "name": name, "pass": psum}
|
||||
return await self.__login()
|
||||
logincmd = {"type": "login", "name": name, "pass": psum}
|
||||
res = await self.__login(logincmd)
|
||||
if res["type"]!="error":
|
||||
self.logincmd = logincmd
|
||||
return res
|
||||
|
||||
async def logout(self):
|
||||
self.logincmd = None
|
||||
@@ -156,8 +160,20 @@ class ServerConnection(BasicServerConnection):
|
||||
nsum = hashlib.md5(new.encode("utf8")).hexdigest()
|
||||
return await super().ask({"type": "changepass", "oldpass": osum, "newpass": nsum})
|
||||
|
||||
async def getuserinfo(self,name_or_id: str|int):
|
||||
if type(name_or_id)==str:
|
||||
return await super().ask({"type": "getuserinfo","name": name_or_id})
|
||||
else:
|
||||
return await super().ask({"type": "getuserinfo","id": name_or_id})
|
||||
|
||||
async def getisettings(self,interface: str):
|
||||
return await super().ask({"type": "getisettings","interface": interface})
|
||||
|
||||
async def setisettings(self,interface: str,settings: dict):
|
||||
return await super().ask({"type": "setisettings","interface": interface,"settings":settings})
|
||||
|
||||
async def banuser(self,uid: str,duration: int=0,motive: None|str=None):
|
||||
return await super().ask({"type": "banuser","user": uid,"duration": duration,"motive": motive})
|
||||
|
||||
async def unbanuser(self,uid: str):
|
||||
return await super().ask({"type": "unbanuser","user": uid})
|
||||
|
||||
Reference in New Issue
Block a user