Skip to content

fix(harmful command): check irc bridge messages too #1000

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ow0cast
Copy link
Contributor

@Ow0cast Ow0cast commented Aug 3, 2025

Description

Makes it so the warning message is also sent when a message is coming from the IRC 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)

see below

Screenshots (if applicable)

image

Additional Information

Please add any other information that is important to this PR.

Summary by Sourcery

Bug Fixes:

  • Allow harmful command detection to apply to messages from the IRC bridge

Copy link
Contributor

sourcery-ai bot commented Aug 3, 2025

Reviewer's Guide

Extend the harmful message handler to process IRC bridge messages by refining the bot filter to respect a whitelist of bridge webhook IDs.

Sequence diagram for harmful message handling with IRC bridge support

sequenceDiagram
    participant Discord
    participant EventHandler as HarmfulMessageHandler
    participant Config
    Discord->>EventHandler: handle_harmful_message(message)
    EventHandler->>EventHandler: Check if message.author.bot
    EventHandler->>Config: Check if message.webhook_id in BRIDGE_WEBHOOK_IDS
    alt Bot and not from bridge webhook
        EventHandler-->>Discord: Return (do nothing)
    else Not a bot or from bridge webhook
        EventHandler->>EventHandler: Process message (strip formatting, etc.)
    end
Loading

File-Level Changes

Change Details Files
Allow IRC bridge bot messages through harmful message guard
  • Augment the existing bot author check to also verify webhook_id against CONFIG.BRIDGE_WEBHOOK_IDS
  • Update the conditional to if message.author.bot and message.webhook_id not in CONFIG.BRIDGE_WEBHOOK_IDS
tux/handlers/event.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented Aug 3, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 9.56%. Comparing base (85084b5) to head (6f8d725).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
tux/handlers/event.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1000      +/-   ##
========================================
- Coverage   9.57%   9.56%   -0.01%     
========================================
  Files        123     123              
  Lines      10415   10415              
  Branches    1279    1279              
========================================
- Hits         997     996       -1     
- Misses      9316    9317       +1     
  Partials     102     102              
Flag Coverage Δ *Carryforward flag
database 0.31% <ø> (+<0.01%) ⬆️ Carriedforward from 85084b5
integration 5.85% <0.00%> (ø)
unit 6.30% <0.00%> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
Core Bot Infrastructure 16.43% <ø> (ø)
Database Layer 0.00% <ø> (ø)
Bot Commands & Features 0.00% <ø> (ø)
Event & Error Handling ∅ <ø> (∅)
Utilities & Helpers ∅ <ø> (∅)
User Interface Components 0.00% <ø> (ø)
CLI Interface ∅ <ø> (∅)
External Service Wrappers ∅ <ø> (∅)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@electron271
Copy link
Member

CONGRATULATIONS ON THE 1000TH PULL/ISSUE

@Ow0cast
Copy link
Contributor Author

Ow0cast commented Aug 3, 2025

yeah i had this change in the back of my mind for a while and saw you saying we were one away in atl.dev

tee hee :3

Copy link
Collaborator

@cherryl1k cherryl1k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like its working as intended
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants