-
-
Notifications
You must be signed in to change notification settings - Fork 41
feat(command): allow irc users to use snippet command #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideIntroduces support for the IRC bridge to trigger only the snippet command by detecting webhook messages, invoking the bot’s context, and exposing a new bridge webhook ID configuration. Sequence diagram for IRC bridge triggering the snippet commandsequenceDiagram
participant IRC_User as actor IRC User
participant IRC_Bridge as IRC Bridge (Webhook)
participant Discord as Discord Server
participant Bot as Bot
participant Handler as Event Handler
IRC_User->>IRC_Bridge: Send snippet command
IRC_Bridge->>Discord: Post message via webhook
Discord->>Handler: on_message(message)
Handler->>Handler: Check if webhook_id in BRIDGE_WEBHOOK_IDS
Handler->>Handler: Check if message is snippet command
Handler->>Bot: get_context(message)
Handler->>Bot: invoke(ctx)
Bot->>Discord: Execute snippet command
Class diagram for updated Config structure with IRC bridge supportclassDiagram
class Config {
+BOT_TOKEN: str
+LIMIT_TO_ROLE_IDS: bool
+ACCESS_ROLE_IDS: list[int]
+BRIDGE_WEBHOOK_IDS: list[int]
}
class CONFIG {
<<instance of Config>>
}
CONFIG --|> Config
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Ow0cast - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `tux/utils/config.py:156` </location>
<code_context>
ACCESS_ROLE_IDS: Final[list[int]] = config["SNIPPETS"]["ACCESS_ROLE_IDS"]
+ # IRC Bridges
+ BRIDGE_WEBHOOK_IDS: Final[list[int]] = config["IRC"]["BRIDGE_WEBHOOK_IDS"]
+
</code_context>
<issue_to_address>
Type of BRIDGE_WEBHOOK_IDS may not be enforced at runtime.
If BRIDGE_WEBHOOK_IDS is loaded as strings, comparisons to integers may fail. Normalize to int when loading the config to avoid subtle bugs.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
BRIDGE_WEBHOOK_IDS: Final[list[int]] = config["IRC"]["BRIDGE_WEBHOOK_IDS"]
=======
BRIDGE_WEBHOOK_IDS: Final[list[int]] = [int(x) for x in config["IRC"]["BRIDGE_WEBHOOK_IDS"]]
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
electron271
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix tests and clarify settings.yml.example
# 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
IRC:
BRIDGE_WEBHOOK_IDS:
- 123456789012345679
- 123456789012345679
- 123456789012345679
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

Description
Allows users from the IRC to run snippet command via the bridge
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
Created webhook in test server and ran snippet command and help command. only snippet command worked
Screenshots (if applicable)
Please add screenshots to help explain your changes.
Additional Information
Please add any other information that is important to this PR.
context as to why its only the snippet command: https://discord.com/channels/1184229800332771328/1273687471732949085/1400580384105955338
Summary by Sourcery
Enable the snippet command for users messaging through an IRC bridge by whitelisting specific webhook IDs and adding the corresponding configuration option.
New Features:
Enhancements:
Documentation: