|
|
@ -163,10 +163,12 @@ class Player: |
|
|
|
result = await response.text() |
|
|
|
if response.status == 200: |
|
|
|
return "Кикнут с серверов" |
|
|
|
if response.status == 404: |
|
|
|
elif response.status == 404: |
|
|
|
raise NotFoundPlayerOnServer |
|
|
|
if response.status == 403: |
|
|
|
elif response.status == 403: |
|
|
|
raise LowPermition |
|
|
|
elif response.status == 406: |
|
|
|
raise AdminLowPermition |
|
|
|
raise UnknownBackendResponse |
|
|
|
|
|
|
|
async def rcon(self, command, args): |
|
|
@ -190,13 +192,33 @@ class Player: |
|
|
|
"secretkey":os.getenv("BACKEND_SECRETKEY"), |
|
|
|
"steam64": self.requester_steam64}) as session: |
|
|
|
async with session.post(f"{os.getenv('BACKEND_URL')}/api/admin/ban?steam64={self.steam64}&ban_reason={reason}&ban_length={minutes}", ssl=False) as response: |
|
|
|
await response.text() |
|
|
|
ban_id = await response.text() |
|
|
|
if response.status == 201: |
|
|
|
return "Игрок забанен или уже был в бане" |
|
|
|
if response.status == 404: |
|
|
|
return f"Игрок теперь забанен! Ид бана: #{ban_id}" |
|
|
|
elif response.status == 202: |
|
|
|
return f"Игрок уже в бане! Ид бана #{ban_id}" |
|
|
|
elif response.status == 404: |
|
|
|
raise NotFoundPlayerOnServer |
|
|
|
if response.status == 403: |
|
|
|
elif response.status == 403: |
|
|
|
raise LowPermition |
|
|
|
elif response.status == 406: |
|
|
|
raise AdminLowPermition |
|
|
|
raise UnknownBackendResponse |
|
|
|
|
|
|
|
async def unban(self): |
|
|
|
async with aiohttp.ClientSession(cookies={ |
|
|
|
"secretkey":os.getenv("BACKEND_SECRETKEY"), |
|
|
|
"steam64": self.requester_steam64}) as session: |
|
|
|
async with session.post(f"{os.getenv('BACKEND_URL')}/api/admin/unban?steam64={self.steam64}", ssl=False) as response: |
|
|
|
ban_id = await response.text() |
|
|
|
if response.status == 200: |
|
|
|
return f"Игрок теперь разбанен!" |
|
|
|
elif response.status == 404: |
|
|
|
return f"Игрок не в бане(" |
|
|
|
elif response.status == 403: |
|
|
|
raise LowPermition |
|
|
|
elif response.status == 406: |
|
|
|
raise AdminLowPermition |
|
|
|
raise UnknownBackendResponse |
|
|
|
|
|
|
|
############### |
|
|
|