Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/settings.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,11 @@ GIF_LIMITER: # Limits the amount of gifs a user can send in a channel
"123456789012345": 2
GIF_LIMITS_CHANNEL:
"123456789012345": 3

# If you do not have an IRC bridge running, ignore these options
# Allows messages from these webhooks to use only the $s and $snippet commands (for now)
IRC:
BRIDGE_WEBHOOK_IDS:
- 123456789012345679
- 123456789012345679
- 123456789012345679
2 changes: 2 additions & 0 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
SNIPPETS:
LIMIT_TO_ROLE_IDS: false
ACCESS_ROLE_IDS: []
IRC:
BRIDGE_WEBHOOK_IDS: []
"""
mock_read_text.return_value = mock_config_content
import tux.main
Expand Down
9 changes: 9 additions & 0 deletions tux/handlers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tux.bot import Tux
from tux.database.controllers import DatabaseController
from tux.ui.embeds import EmbedCreator, EmbedType
from tux.utils.config import CONFIG

Check warning on line 7 in tux/handlers/event.py

View check run for this annotation

Codecov / codecov/patch

tux/handlers/event.py#L7

Added line #L7 was not covered by tests
from tux.utils.functions import is_harmful, strip_formatting


Expand Down Expand Up @@ -68,6 +69,14 @@

@commands.Cog.listener()
async def on_message(self, message: discord.Message) -> None:
# Allow the IRC bridge to use the snippet command only
if message.webhook_id in CONFIG.BRIDGE_WEBHOOK_IDS and (
message.content.startswith(f"{CONFIG.DEFAULT_PREFIX}s ")
or message.content.startswith(f"{CONFIG.DEFAULT_PREFIX}snippet ")
):
ctx = await self.bot.get_context(message)
await self.bot.invoke(ctx)

Check warning on line 78 in tux/handlers/event.py

View check run for this annotation

Codecov / codecov/patch

tux/handlers/event.py#L77-L78

Added lines #L77 - L78 were not covered by tests

await self.handle_harmful_message(message)

@commands.Cog.listener()
Expand Down
3 changes: 3 additions & 0 deletions tux/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,8 @@ def BOT_TOKEN(self) -> str: # noqa: N802
LIMIT_TO_ROLE_IDS: Final[bool] = config["SNIPPETS"]["LIMIT_TO_ROLE_IDS"]
ACCESS_ROLE_IDS: Final[list[int]] = config["SNIPPETS"]["ACCESS_ROLE_IDS"]

# IRC Bridges
BRIDGE_WEBHOOK_IDS: Final[list[int]] = [int(x) for x in config["IRC"]["BRIDGE_WEBHOOK_IDS"]]


CONFIG = Config()
Loading