mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16:19 +00:00
[MODERATION] Removed unused outdated function
Function that needed Google API, that I don't want mandatory
This commit is contained in:
@@ -4,7 +4,6 @@ import os
|
|||||||
from config import debug, curs_data, con_data
|
from config import debug, curs_data, con_data
|
||||||
import openai
|
import openai
|
||||||
import requests
|
import requests
|
||||||
import toxicity as tox # this is a file called toxicity.py, which contains the toxicity function that allows you to check if a message is toxic or not (it uses the perspective api)
|
|
||||||
|
|
||||||
|
|
||||||
class Moderation(discord.Cog):
|
class Moderation(discord.Cog):
|
||||||
@@ -76,6 +75,8 @@ class Moderation(discord.Cog):
|
|||||||
obscene: float = None,
|
obscene: float = None,
|
||||||
spam: float = None,
|
spam: float = None,
|
||||||
):
|
):
|
||||||
|
# local import, because we don't want to import the toxicity function if the moderation is disabled
|
||||||
|
# import toxicity as tox # this is a file called toxicity.py, which contains the toxicity function that allows you to check if a message is toxic or not (it uses the perspective api)
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
"Our moderation capabilities have been switched to our new 100% free and open-source AI discord moderation bot! You add it to your server here: https://discord.com/api/oauth2/authorize?client_id=1071451913024974939&permissions=1377342450896&scope=bot and you can find the source code here: https://github.com/Paillat-dev/Moderator/ \n If you need help, you can join our support server here: https://discord.gg/pB6hXtUeDv",
|
"Our moderation capabilities have been switched to our new 100% free and open-source AI discord moderation bot! You add it to your server here: https://discord.com/api/oauth2/authorize?client_id=1071451913024974939&permissions=1377342450896&scope=bot and you can find the source code here: https://github.com/Paillat-dev/Moderator/ \n If you need help, you can join our support server here: https://discord.gg/pB6hXtUeDv",
|
||||||
ephemeral=True,
|
ephemeral=True,
|
||||||
@@ -86,89 +87,90 @@ class Moderation(discord.Cog):
|
|||||||
await ctx.respond("Moderation disabled!", ephemeral=True)
|
await ctx.respond("Moderation disabled!", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
@discord.Cog.listener()
|
# Moderation has been moved to a new bot..
|
||||||
async def on_message(self, message: discord.Message):
|
# @discord.Cog.listener()
|
||||||
if message.author == self.bot.user:
|
# async def on_message(self, message: discord.Message):
|
||||||
return
|
# if message.author == self.bot.user:
|
||||||
try:
|
# return
|
||||||
curs_data.execute(
|
# try:
|
||||||
"SELECT * FROM moderation WHERE guild_id = ?", (str(message.guild.id),)
|
# curs_data.execute(
|
||||||
)
|
# "SELECT * FROM moderation WHERE guild_id = ?", (str(message.guild.id),)
|
||||||
except:
|
# )
|
||||||
return
|
# except:
|
||||||
data = curs_data.fetchone()
|
# return
|
||||||
if data is None:
|
# data = curs_data.fetchone()
|
||||||
return
|
# if data is None:
|
||||||
channel = self.bot.get_channel(int(data[1]))
|
# return
|
||||||
is_enabled = data[2]
|
# channel = self.bot.get_channel(int(data[1]))
|
||||||
moderator_role = message.guild.get_role(int(data[3]))
|
# is_enabled = data[2]
|
||||||
# we also do that with the manage_messages permission, so the moderators can't be moderated
|
# moderator_role = message.guild.get_role(int(data[3]))
|
||||||
if message.author.guild_permissions.manage_messages:
|
# # we also do that with the manage_messages permission, so the moderators can't be moderated
|
||||||
return # if the user is a moderator, we don't want to moderate him because he is allowed to say whatever he wants because he is just like a dictator
|
# if message.author.guild_permissions.manage_messages:
|
||||||
if message.author.guild_permissions.administrator:
|
# return # if the user is a moderator, we don't want to moderate him because he is allowed to say whatever he wants because he is just like a dictator
|
||||||
return # if the user is an administrator, we don't want to moderate him because he is allowed to say whatever he wants because he is a DICTATOR
|
# if message.author.guild_permissions.administrator:
|
||||||
if not is_enabled:
|
# return # if the user is an administrator, we don't want to moderate him because he is allowed to say whatever he wants because he is a DICTATOR
|
||||||
return
|
# if not is_enabled:
|
||||||
content = message.content
|
# return
|
||||||
message_toxicity = tox.get_toxicity(content)
|
# content = message.content
|
||||||
reasons_to_delete = []
|
# message_toxicity = tox.get_toxicity(content)
|
||||||
reasons_to_suspicous = []
|
# reasons_to_delete = []
|
||||||
for i in message_toxicity:
|
# reasons_to_suspicous = []
|
||||||
if i >= float(data[message_toxicity.index(i) + 4]):
|
# for i in message_toxicity:
|
||||||
reasons_to_delete.append(tox.toxicity_names[message_toxicity.index(i)])
|
# if i >= float(data[message_toxicity.index(i) + 4]):
|
||||||
for i in message_toxicity:
|
# reasons_to_delete.append(tox.toxicity_names[message_toxicity.index(i)])
|
||||||
if (
|
# for i in message_toxicity:
|
||||||
float(data[message_toxicity.index(i) + 4] - 0.1)
|
# if (
|
||||||
<= i
|
# float(data[message_toxicity.index(i) + 4] - 0.1)
|
||||||
< float(data[message_toxicity.index(i) + 4])
|
# <= i
|
||||||
):
|
# < float(data[message_toxicity.index(i) + 4])
|
||||||
reasons_to_suspicous.append(
|
# ):
|
||||||
tox.toxicity_names[message_toxicity.index(i)]
|
# reasons_to_suspicous.append(
|
||||||
)
|
# tox.toxicity_names[message_toxicity.index(i)]
|
||||||
if len(reasons_to_delete) > 0:
|
# )
|
||||||
embed = discord.Embed(
|
# if len(reasons_to_delete) > 0:
|
||||||
title="Message deleted",
|
# embed = discord.Embed(
|
||||||
description=f"Your message was deleted because it was too toxic. The following reasons were found: **{'**, **'.join(reasons_to_delete)}**",
|
# title="Message deleted",
|
||||||
color=discord.Color.red(),
|
# description=f"Your message was deleted because it was too toxic. The following reasons were found: **{'**, **'.join(reasons_to_delete)}**",
|
||||||
)
|
# color=discord.Color.red(),
|
||||||
await message.reply(
|
# )
|
||||||
f"{message.author.mention}", embed=embed, delete_after=15
|
# await message.reply(
|
||||||
)
|
# f"{message.author.mention}", embed=embed, delete_after=15
|
||||||
await message.delete()
|
# )
|
||||||
embed = discord.Embed(
|
# await message.delete()
|
||||||
title="Message deleted",
|
# embed = discord.Embed(
|
||||||
description=f"**{message.author}**'s message ***{content}*** was deleted because it was too toxic. The following reasons were found:",
|
# title="Message deleted",
|
||||||
color=discord.Color.red(),
|
# description=f"**{message.author}**'s message ***{content}*** was deleted because it was too toxic. The following reasons were found:",
|
||||||
)
|
# color=discord.Color.red(),
|
||||||
for i in reasons_to_delete:
|
# )
|
||||||
toxicity_value = message_toxicity[tox.toxicity_names.index(i)]
|
# for i in reasons_to_delete:
|
||||||
embed.add_field(
|
# toxicity_value = message_toxicity[tox.toxicity_names.index(i)]
|
||||||
name=i,
|
# embed.add_field(
|
||||||
value=f"Found toxicity value: **{toxicity_value*100}%**",
|
# name=i,
|
||||||
inline=False,
|
# value=f"Found toxicity value: **{toxicity_value*100}%**",
|
||||||
)
|
# inline=False,
|
||||||
await channel.send(embed=embed)
|
# )
|
||||||
elif len(reasons_to_suspicous) > 0:
|
# await channel.send(embed=embed)
|
||||||
await message.reply(
|
# elif len(reasons_to_suspicous) > 0:
|
||||||
f"{moderator_role.mention} This message might be toxic. The following reasons were found: **{'**, **'.join(reasons_to_suspicous)}**",
|
# await message.reply(
|
||||||
delete_after=15,
|
# f"{moderator_role.mention} This message might be toxic. The following reasons were found: **{'**, **'.join(reasons_to_suspicous)}**",
|
||||||
mention_author=False,
|
# delete_after=15,
|
||||||
)
|
# mention_author=False,
|
||||||
embed = discord.Embed(
|
# )
|
||||||
title="Message suspicious",
|
# embed = discord.Embed(
|
||||||
description=f"**{message.author}**'s message [***{content}***]({message.jump_url}) might be toxic. The following reasons were found:",
|
# title="Message suspicious",
|
||||||
color=discord.Color.orange(),
|
# description=f"**{message.author}**'s message [***{content}***]({message.jump_url}) might be toxic. The following reasons were found:",
|
||||||
)
|
# color=discord.Color.orange(),
|
||||||
for i in reasons_to_suspicous:
|
# )
|
||||||
toxicity_value = message_toxicity[tox.toxicity_names.index(i)]
|
# for i in reasons_to_suspicous:
|
||||||
embed.add_field(
|
# toxicity_value = message_toxicity[tox.toxicity_names.index(i)]
|
||||||
name=i,
|
# embed.add_field(
|
||||||
value=f"Found toxicity value: **{toxicity_value*100}%**",
|
# name=i,
|
||||||
inline=False,
|
# value=f"Found toxicity value: **{toxicity_value*100}%**",
|
||||||
)
|
# inline=False,
|
||||||
await channel.send(embed=embed)
|
# )
|
||||||
# we add a reaction to the message so the moderators can easily find it orange circle emoji
|
# await channel.send(embed=embed)
|
||||||
await message.add_reaction("🟠")
|
# # we add a reaction to the message so the moderators can easily find it orange circle emoji
|
||||||
|
# await message.add_reaction("🟠")
|
||||||
|
|
||||||
@discord.slash_command(
|
@discord.slash_command(
|
||||||
name="get_toxicity", description="Get the toxicity of a message"
|
name="get_toxicity", description="Get the toxicity of a message"
|
||||||
|
|||||||
Reference in New Issue
Block a user