Skip to content

Commit 2d6aec2

Browse files
committed
feat(command): allow irc users to use snippet command
1 parent 784e178 commit 2d6aec2

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

config/settings.yml.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,9 @@ GIF_LIMITER: # Limits the amount of gifs a user can send in a channel
114114
"123456789012345": 2
115115
GIF_LIMITS_CHANNEL:
116116
"123456789012345": 3
117+
118+
IRC: # IDs of the IRC bridge webhooks
119+
BRIDGE_WEBHOOK_IDS:
120+
- 123456789012345679
121+
- 123456789012345679
122+
- 123456789012345679

tux/handlers/event.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from tux.bot import Tux
55
from tux.database.controllers import DatabaseController
66
from tux.ui.embeds import EmbedCreator, EmbedType
7+
from tux.utils.config import CONFIG
78
from tux.utils.functions import is_harmful, strip_formatting
89

910

@@ -68,6 +69,14 @@ async def on_message_edit(self, before: discord.Message, after: discord.Message)
6869

6970
@commands.Cog.listener()
7071
async def on_message(self, message: discord.Message) -> None:
72+
# Allow the IRC bridge to use the snippet command only
73+
if message.webhook_id in CONFIG.BRIDGE_WEBHOOK_IDS and (
74+
message.content.startswith(f"{CONFIG.DEFAULT_PREFIX}s ")
75+
or message.content.startswith(f"{CONFIG.DEFAULT_PREFIX}snippet ")
76+
):
77+
ctx = await self.bot.get_context(message)
78+
await self.bot.invoke(ctx)
79+
7180
await self.handle_harmful_message(message)
7281

7382
@commands.Cog.listener()

tux/utils/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,8 @@ def BOT_TOKEN(self) -> str: # noqa: N802
152152
LIMIT_TO_ROLE_IDS: Final[bool] = config["SNIPPETS"]["LIMIT_TO_ROLE_IDS"]
153153
ACCESS_ROLE_IDS: Final[list[int]] = config["SNIPPETS"]["ACCESS_ROLE_IDS"]
154154

155+
# IRC Bridges
156+
BRIDGE_WEBHOOK_IDS: Final[list[int]] = config["IRC"]["BRIDGE_WEBHOOK_IDS"]
157+
155158

156159
CONFIG = Config()

0 commit comments

Comments
 (0)