Browse Source

fixes

master
gsd 6 days ago
parent
commit
ba1c375861
  1. 45
      bot.py
  2. 4
      other_ext/kamaz_ai.py
  3. 16
      other_ext/url_checker.py
  4. 12
      other_ext/webhook_helper.py
  5. 9
      user_ext/profile.py
  6. 6
      user_ext/servers.py

45
bot.py

@ -109,25 +109,32 @@ class DiscordClient(commands.Bot):
return await interaction.followup.send("Эту команду можно выполнить только на сервере где есть проверка ролей доступа!", ephemeral=True)
elif isinstance(error, CommandNotFound):
return await interaction.followup.send("У меня нет такой команды, возможно и есть...", ephemeral=True)
elif isinstance(error.original, CannotCastToSteamID):
return await interaction.followup.send("Не возможно найти такой профиль, попробуй написать иные данные!", ephemeral=True)
elif isinstance(error.original, discord.app_commands.errors.NoPrivateMessage):
return await interaction.followup.send("Вызванная тобой команда не работает в личных сообщениях", ephemeral=False)
elif isinstance(error.original, LowPermition):
return await interaction.followup.send("Это не для тебя и не для таких как ты сделано...", ephemeral=True)
elif isinstance(error.original, AdminLowPermition):
return await interaction.followup.send("Нельзя сделать это действие, ибо ты крут, но не настолько чтоб это совершить", ephemeral=True)
elif isinstance(error.original, NotFoundPlayerOnServer):
return await interaction.followup.send("Игрок не найден на серверах", ephemeral=True)
elif isinstance(error.original, UnknownBackendResponse):
traceback.print_exc()
return await interaction.followup.send(f"Ошибка на стороне сервера в исполнении говнокода, стоит подождать или позвать помощь. Ответ сервера: {error.original.status_code}", ephemeral=False)
elif isinstance(error.original, discord.errors.NotFound):
return await interaction.followup.send("Слишком долгий ответ со стороны сервера, причины:\n1) Возможно бекенд сдох\n2)Cлишком долгий незапланированный ответ с сервера\n3)Стоит позвать помощь", ephemeral=True)
elif isinstance(error.original, NeedDiscordAuthOfSteam):
return await interaction.followup.send("У тебя не привязан профиль стима к дискорду, ничего подобного делать тебе нельзя", ephemeral=True)
elif isinstance(error.original, ClientConnectionError):
return await interaction.followup.send("Сервис фактов13 не дал ответ, вероятно он умер, поэтому стоит немного подождать и может что-то изменится", ephemeral=True)
elif isinstance(error, NoPrivateMessage):
return await interaction.followup.send("Чел... эту команду нельзя выполнять в ЛС, только публично чтобы все видели какой ты лох", ephemeral=False)
elif isinstance(error, discord.errors.NotFound):
return await interaction.followup.send("Слишком долгий ответ со стороны сервера, причины:\n1) Возможно бекенд сдох\n2)Cлишком долгий незапланированный ответ с сервера\n3)Стоит позвать помощь", ephemeral=False)
elif isinstance(error, ClientConnectionError):
return await interaction.followup.send("Сервис фактов13 не дал ответ, вероятно он умер, поэтому стоит немного подождать и может что-то изменится", ephemeral=False)
else:
if hasattr(error, "original"):
if False:#я ленивая жопа
pass
elif isinstance(error.original, CannotCastToSteamID):
return await interaction.followup.send("Не возможно найти такой профиль, попробуй написать иные данные!", ephemeral=True)
elif isinstance(error.original, LowPermition):
return await interaction.followup.send("Это не для тебя и не для таких как ты сделано...", ephemeral=True)
elif isinstance(error.original, AdminLowPermition):
return await interaction.followup.send("Нельзя сделать это действие, ибо ты крут, но не настолько чтоб это совершить", ephemeral=True)
elif isinstance(error.original, NotFoundPlayerOnServer):
return await interaction.followup.send("Игрок не найден на серверах", ephemeral=True)
elif isinstance(error.original, UnknownBackendResponse):
traceback.print_exc()
return await interaction.followup.send(f"Ошибка на стороне сервера в исполнении говнокода, стоит подождать или позвать помощь. Ответ сервера: {error.original.status_code}", ephemeral=False)
elif isinstance(error.original, NeedDiscordAuthOfSteam):
return await interaction.followup.send("У тебя не привязан профиль стима к дискорду, ничего подобного делать тебе нельзя", ephemeral=True)
elif isinstance(error.original, ClientConnectionError):
return await interaction.followup.send("Сервис фактов13 не дал ответ, вероятно он умер, поэтому стоит немного подождать и может что-то изменится", ephemeral=True)
traceback.print_exc()
return await interaction.followup.send("Возникла необратимая ошибка, хз что случилось. Попробуй еще раз!", ephemeral=True)

4
other_ext/kamaz_ai.py

@ -29,7 +29,7 @@ MAX_PERMISSION_LEVEL = 4
class KamazAI_v1_3:
def __init__(self, report_list):
self.k_neighbors = 5
self.k_neighbors = 10
self.weights = {
'steam_identity': 0.35,
'reason': 0.15,
@ -246,7 +246,7 @@ class KamazAI_v1_1:
'server': 0.1
}
K_NEIGHBORS = 5
K_NEIGHBORS = 10
'''
{

16
other_ext/url_checker.py

@ -1,6 +1,7 @@
from discord.ext import tasks, commands
import discord
import re, os
import base64
class Extension:
allow_domains = ["steamcommunity.com","s.team","tenor.com","tf2.pblr-nyk.pro", "pblr-nyk.pro", "youtu.be", "youtube.com"]
@ -33,8 +34,11 @@ class Extension:
for maybe_url in reversed(re.findall(self.WEB_URL_REGEX, message.content)):
for rid in self.allow_roles:
if message.author.get_role(rid):
return
try:
if message.author.get_role(rid):
return
except AttributeError:
pass
sub_continue = False
for domain in self.allow_domains:
@ -46,8 +50,14 @@ class Extension:
print(f"Found url from {message.author} with url {maybe_url}")
original_text = ""
try:
await message.reply(f"{message.author.mention} ссылки кидать нельзя!\nhttps://tf2.pblr-nyk.pro/fekalis/nigger_maslo.gif", delete_after = 60)
original_text = base64.b64encode(message.content.encode("utf-8")).decode("utf-8")
except:
pass
try:
await message.reply(f"{message.author.mention} ссылки кидать нельзя!\nhttps://tf2.pblr-nyk.pro/fekalis/nigger_maslo.gif\nОригинальное сообщение в base64: {original_text}", delete_after = 300)
except Exception as err:
print(f"Cannot send message about delete url, error: {err}")

12
other_ext/webhook_helper.py

@ -6,6 +6,7 @@ import traceback
import os
from exceptions import NotFoundPlayerOnServer
import aiohttp
import io
class Extension:
core = None
@ -155,8 +156,15 @@ class Extension:
except NotFoundPlayerOnServer:
return await message.channel.send(content=f"{user.mention}!\nДействие {payload.emoji} сообщило что игрок сейчас не играет на сервере!\nВозможен пиздеж и провокация!", delete_after=60)
except Exception as err:
traceback.print_exc()
return await message.channel.send(content=f"{user.mention}!\nДействие {payload.emoji} невозможно из-за ошибки: {err}. Стоит написать добродею!", delete_after=60)
tracelog = traceback.format_exc()
tracelog = f"executor: {executor}\nkwargs: {kwargs}\n" + tracelog
print(tracelog)
msg_content = f"{user.mention}!\nДействие {payload.emoji} невозможно из-за ошибки: {err}. Стоит написать добродею!"
try:
file = discord.File(io.BytesIO(tracelog.encode("utf-8")), filename="tracelog.txt")
return await message.channel.send(content=msg_content, file=file)
except:
return await message.channel.send(content=msg_content + "\nТут еще должен быть файл ошибок, но его нет")
return await message.channel.send(content=f"{user.mention}!\nДействие {payload.emoji} дало ответ:\n {result}")

9
user_ext/profile.py

@ -53,8 +53,7 @@ class Extension:
return await interaction.followup.send(
content = content_to_response if content_to_response else MISSING,
embed=embed,
file=file,
ephemeral=False)
file=file)
if message:
return await message.channel.send(
content = content_to_response if content_to_response else MISSING,
@ -65,13 +64,11 @@ class Extension:
if interaction:
return await interaction.followup.send(
content = content_to_response if content_to_response else MISSING,
embed=embed,
ephemeral=False)
embed=embed)
if message:
return await message.channel.send(
content = content_to_response if content_to_response else MISSING,
embed=embed,
ephemeral=False)
embed=embed)
raise Exception('Unknown processor')
async def __call__(self, *args, **kwds):

6
user_ext/servers.py

@ -21,7 +21,11 @@ class Extension:
else:
servers = [server for server in core.stats["servers"].values() if server['status'] == True and server['player_count'] > 0]
if servers:
embed.add_field(name = "Где сейчас играют", value = f'{core.stats["statistic"]["player_now"]} карликов', inline=True)
if "statistic" in core.stats and player_now in core.stats["statistic"]:
embed.add_field(name = "Где сейчас играют", value = f'{core.stats["statistic"]["player_now"]} карликов', inline=True)
else:
embed.add_field(name = "Где сейчас играют", value = f'а хуй его бля знает', inline=True)
for server in servers:
embed.add_field(name = server["name"], value=str_server(server), inline=False)

Loading…
Cancel
Save