@ -2,12 +2,7 @@ from email import message
import aiohttp , os
from datetime import datetime
from discord import Embed
class CannotCastToSteamID ( Exception ) :
pass
class NotLoadProfile ( Exception ) :
pass
from exceptions import *
class Player :
original_request = " "
@ -27,7 +22,11 @@ class Player:
self . steamid = await self . GetSteamIDOfProfile ( self . original_request )
async def LoadProfile ( self ) :
self . current = await self . GetProfile ( self . steamid . get ( " steam64 " ) )
self . current = await self . GetProfile ( self . steam64 )
@property
def steam64 ( self ) :
return self . steamid . get ( ' steam64 ' , 0 )
@property
def embed ( self ) - > Embed :
@ -160,15 +159,15 @@ class Player:
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/kick?steam64= { self . steamid . get ( ' steam 64 ' ) } " , ssl = False ) as response :
async with session . post ( f " { os . getenv ( ' BACKEND_URL ' ) } /api/admin/kick?steam64= { self . steam64 } " , ssl = False ) as response :
result = await response . text ( )
if response . status == 200 :
return " Кикнут с серверов "
if response . status == 404 :
return " Игрок не найден на серверах "
raise NotFoundPlayerOnServer
if response . status == 403 :
return " Это не для тебя и не для таких как ты сделано... "
return " помогите я обосрался "
raise LowPermition
raise UnknownBackendResponse
async def rcon ( self , command , args ) :
if not self . current :
@ -184,8 +183,20 @@ class Player:
async with session . post ( f " { os . getenv ( ' BACKEND_URL ' ) } /api/admin/rcon?srv= { server } &command= { final_command } " , ssl = False ) as response :
return await response . text ( )
else :
return " Игрок не играет на серверах "
raise NotFoundPlayerOnServer
async def ban ( self , reason , minutes ) :
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/ban?steam64= { self . steam64 } &ban_reason= { reason } &ban_length= { minutes } " , ssl = False ) as response :
if response . status == 200 :
return " Игрок забанен или уже был в бане "
if response . status == 404 :
raise NotFoundPlayerOnServer
if response . status == 403 :
raise LowPermition
raise UnknownBackendResponse
###############
#user command
@ -194,12 +205,14 @@ class Player:
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/profile/current/report?steam64= { self . steamid . get ( ' steam 64 ' ) } &text= { reason } " , ssl = False ) as response :
async with session . post ( f " { os . getenv ( ' BACKEND_URL ' ) } /api/profile/current/report?steam64= { self . steam64 } &text= { reason } " , ssl = False ) as response :
result = int ( await response . text ( ) )
if result == 0 :
return " Игрок с таким именем не играет на серверах в данный момент "
return " Игрок с таким именем не играет на серверах в данный момент... "
elif result < 0 :
return f " Падажди, следующий репорт можно отправить только после: { - 1 * result } секунд "
else :
return f " Падажди, следующий репорт можно отправить только после: { utime2human ( result ) } "
return f " Репорт отправлен! "
def workshopmap2bsp ( map_name ) :