Skip to content

Commit cd7ba4a

Browse files
authored
Refactor all moderation features, auto mod and notes. Add reports and modlog. (#1095)
This is a complete rewrite and restructure of protect and everything related to it. protect.py was split into: commands/moderator.py commands/purge.py core/moderation.py functions/automod.py functions/paste.py Two additional files were added: commands/modlog.py commands/report.py who.py was split into: commands/notes.py commands/whois.py commands/moderator.py: Moved all moderator actions into slash commands Adds a new /unwarn command allowing individual warnings to be removed Logs and displays who warned people (Fixes #657) Mute can now have both a duration and a reason (fixes #721) commands/modlog.py Completely new feature, copying carlbots /modlog highscores and ban/unban logging This additionally adds the ability to lookup bans by user or moderator Bans are now forever stored in TS database (Fixes #380) commands/notes.py All the notes editing commands, as well as a /notes all Write roles checks now check reader roles as well (fixes #692) Makes notes all paginated (fixes #800) Notes reader/writer now only send one message if config is empty (fixes #983) commands/purge.py Moves purge command to /purge Combines the duration and exact command commands/whois.py Is the /whois command core/moderation.py This handles the core actions of ban/unban/kick/mute/unmute/warn/unwarn and a few core logic items, like getting all warnings functions/automod.py Completely rewrites automod (Fixes #463) Fixes regex not working (no issue for this one) Adds a mute feature for automod (Fixes #1020) Adds automod as a framework instead of a strict class, allowing other modules to run messages through automod Adds IRC checks to automod (Fixes #212) functions/paste.py Paste now makes sure that the linx API request worked and that the message was sent BEFORE deleting the original message (Fixes #1077) Paste checks if message violates automod, and if it was recommended that it was deleted, nothing happens Other: Who now shows new warning information (Fixes #180) Moves duck to use the new core/moderation.py feature
1 parent 6c521f1 commit cd7ba4a

21 files changed

Lines changed: 3291 additions & 1766 deletions

.flake8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
2-
ignore = DCO010, DCO023, DOC503, DOC602, DOC603, E203, E501, E712, F401, F403, F821, W503
2+
ignore = DCO010, DCO023, DOC503, DOC602, DOC603, MDA002, E203, E501, E712, F401, F403, F821, W503
33
style = google
4-
skip-checking-short-docstrings = False
4+
skip-checking-short-docstrings = False

techsupport_bot/bot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ async def create_new_context_config(self: Self, guild_id: str) -> munch.Munch:
329329
config_.rate_limit.enabled = False
330330
config_.rate_limit.commands = 4
331331
config_.rate_limit.time = 10
332+
config_.moderation = munch.DefaultMunch(None)
333+
config_.moderation.max_warnings = 3
334+
config_.moderation.alert_channel = None
332335

333336
config_.extensions = extensions_config
334337

techsupport_bot/commands/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Both app and prefix commands are in this module
44
"""
55

6+
from .application import *
67
from .burn import *
78
from .conch import *
89
from .config import *
@@ -16,6 +17,9 @@
1617
from .linter import *
1718
from .listen import *
1819
from .mock import *
20+
from .moderator import *
21+
from .modlog import *
22+
from .notes import *
1923
from .relay import *
2024
from .roll import *
2125
from .wyr import *

techsupport_bot/commands/application.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def setup(bot: bot.TechSupportBot) -> None:
106106
description=(
107107
"The role IDs required to manage the applications (not required to apply)"
108108
),
109-
default=[""],
109+
default=[],
110110
)
111111
config.add(
112112
key="ping_role",
@@ -150,6 +150,8 @@ async def command_permission_check(interaction: discord.Interaction) -> bool:
150150
# Gets permitted roles
151151
allowed_roles = []
152152
for role_id in config.extensions.application.manage_roles.value:
153+
if not role_id:
154+
continue
153155
role = interaction.guild.get_role(int(role_id))
154156
if not role:
155157
continue

techsupport_bot/commands/duck.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import munch
1414
import ui
1515
from botlogging import LogContext, LogLevel
16-
from core import auxiliary, cogs, extensionconfig
16+
from core import auxiliary, cogs, extensionconfig, moderation
1717
from discord import Color as embed_colors
1818
from discord.ext import commands
1919

@@ -394,9 +394,12 @@ def message_check(
394394
and channel.guild.me.guild_permissions.moderate_members
395395
):
396396
asyncio.create_task(
397-
message.author.timeout(
398-
timedelta(seconds=config.extensions.duck.cooldown.value),
397+
moderation.mute_user(
398+
user=message.author,
399399
reason="Missed a duck",
400+
duration=timedelta(
401+
seconds=config.extensions.duck.cooldown.value
402+
),
400403
)
401404
)
402405

0 commit comments

Comments
 (0)