Browse Source

говняк с микрофоном

huy
gsd 2 years ago
parent
commit
3cf3ccc83a
  1. 19
      admin_ext/mute.py
  2. 19
      admin_ext/unmute.py
  3. 32
      player.py

19
admin_ext/mute.py

@ -0,0 +1,19 @@
import discord
class Extension:
core = None
def __init__(self, core):
self.core = core
@core.tree.command(name = "mute", description = "Выключить микрофон")
@discord.app_commands.describe(profile=core.ANY_INPUT)
async def mute_player(
interaction: discord.Interaction,
profile: str
):
await interaction.response.defer(thinking=True)
return await interaction.followup.send(f'{await self.__call__(profile, interaction.user)}', ephemeral=False)
async def __call__(self, profile, discord_user):
steam64 = await self.core.GetSteam64OfDiscord(discord_user)
player = await self.core.GetPlayer(profile, steam64, False)
return await player.mute()

19
admin_ext/unmute.py

@ -0,0 +1,19 @@
import discord
class Extension:
core = None
def __init__(self, core):
self.core = core
@core.tree.command(name = "unmute", description = "Включить микрофон")
@discord.app_commands.describe(profile=core.ANY_INPUT)
async def unmute_player(
interaction: discord.Interaction,
profile: str
):
await interaction.response.defer(thinking=True)
return await interaction.followup.send(f'{await self.__call__(profile, interaction.user)}', ephemeral=False)
async def __call__(self, profile, discord_user):
steam64 = await self.core.GetSteam64OfDiscord(discord_user)
player = await self.core.GetPlayer(profile, steam64, False)
return await player.unmute()

32
player.py

@ -228,6 +228,38 @@ class Player:
raise AdminLowPermition raise AdminLowPermition
raise UnknownBackendResponse raise UnknownBackendResponse
async def mute(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/mute?steam64={self.steam64}", ssl=False) as response:
result = await response.text()
if response.status == 200:
return "Выключен микрофон"
elif response.status == 404:
raise NotFoundPlayerOnServer
elif response.status == 403:
raise LowPermition
elif response.status == 406:
raise AdminLowPermition
raise UnknownBackendResponse
async def unmute(self):
async with aiohttp.ClientSession(cookies={
"secretkey":os.getenv("BACKEND_SECRETKEY"),
"steam64": self.requester_steam64}) as session:
async with session.delete(f"{os.getenv('BACKEND_URL')}/api/admin/mute?steam64={self.steam64}", ssl=False) as response:
result = await response.text()
if response.status == 200:
return "Включен микрофон"
elif response.status == 404:
raise NotFoundPlayerOnServer
elif response.status == 403:
raise LowPermition
elif response.status == 406:
raise AdminLowPermition
raise UnknownBackendResponse
async def rcon(self, command, args): async def rcon(self, command, args):
if not self.current: if not self.current:
return "добродей дурачек забыл прогрузить профиль" return "добродей дурачек забыл прогрузить профиль"

Loading…
Cancel
Save