[V3 Filter] Unable to filter sentences #1904

Closed
opened 2018-06-30 03:00:12 +02:00 by Crossedfall · 8 comments
Crossedfall commented 2018-06-30 03:00:12 +02:00 (Migrated from github.com)

Command bugs

Command name

filter add "<sentence>"

What cog is this command from?

Filter [core]

What were you expecting to happen?

Whenever the full sentence is posted within the filtered Discord server, it should be removed by the bot.

What actually happened?

Nothing. Sentences will be deleted if you remove the spaces from the trigger phrase, however.

How can we reproduce this issue?

  1. Create a new filter with spaces
  2. Attempt to trigger the filter

filter gif

Note: it would seem that some sentences are read whereas most are not. Multiple tests are advised

Red Version

image

# Command bugs <!-- Did you find a bug with a command? Fill out the following: --> #### Command name `filter add "<sentence>"` #### What cog is this command from? Filter [core] #### What were you expecting to happen? Whenever the full sentence is posted within the filtered Discord server, it should be removed by the bot. #### What actually happened? Nothing. Sentences will be deleted if you remove the spaces from the trigger phrase, however. #### How can we reproduce this issue? 1. Create a new filter with spaces 2. Attempt to trigger the filter ![filter gif](https://user-images.githubusercontent.com/26130695/42119867-c0200498-7bd6-11e8-9c8e-689eb104a67a.gif) _Note: it would seem that some sentences are read whereas most are not. Multiple tests are advised_ #### Red Version ![image](https://user-images.githubusercontent.com/26130695/42119883-e7749ff4-7bd6-11e8-9b0e-75283ea3d080.png)
mikeshardmind commented 2018-07-02 08:06:58 +02:00 (Migrated from github.com)

Unfortunately, that gif isn't a demonstration of anything not working.

The filter will never impact other bots, the bot owner, mods or admins:

github.com/Cog-Creators/Red-DiscordBot@3bcf375204/redbot/cogs/filter/filter.py (L248-L251)

github.com/Cog-Creators/Red-DiscordBot@3bcf375204/redbot/core/utils/mod.py (L143-L150)

if you need to test filter's behavior, if you launch the bot with --dev you can use [p]mockmsg or you can get someone else to help you test it.

Unfortunately, that gif isn't a demonstration of anything not working. The filter will never impact other bots, the bot owner, mods or admins: https://github.com/Cog-Creators/Red-DiscordBot/blob/3bcf375204c22271ad3ed1fc059b598b751aa03f/redbot/cogs/filter/filter.py#L248-L251 https://github.com/Cog-Creators/Red-DiscordBot/blob/3bcf375204c22271ad3ed1fc059b598b751aa03f/redbot/core/utils/mod.py#L143-L150 if you need to test filter's behavior, if you launch the bot with `--dev` you can use `[p]mockmsg` or you can get someone else to help you test it.
Crossedfall commented 2018-07-02 08:23:08 +02:00 (Migrated from github.com)

@mikeshardmind if you watch the gif to the end you'll note that it filters the message if I remove all of the spaces. That'd imply that it does actually filter messages from a bot owner and guild admin.

If it really isn't supposed to do that, then there might be another issue at play, possibly unrelated to this report.

Edit: I have tested this with other users and in other servers. I can confirm that even without this oddity it still happens.

@mikeshardmind if you watch the gif to the end you'll note that it filters the message if I remove all of the spaces. That'd imply that it does actually filter messages from a bot owner and guild admin. If it really isn't supposed to do that, then there might be another issue at play, possibly unrelated to this report. Edit: I have tested this with other users and in other servers. I can confirm that even without this oddity it still happens.
mikeshardmind commented 2018-07-02 08:24:37 +02:00 (Migrated from github.com)

Does the audit log confirm it was your bot, and are you running more than one bot on that token?

If the answer to those is "yes" and "no" respectively, something is seriously wrong here.

Does the audit log confirm it was your bot, and are you running more than one bot on that token? If the answer to those is "yes" and "no" respectively, something is seriously wrong here.
Crossedfall commented 2018-07-02 08:36:13 +02:00 (Migrated from github.com)

As far as I can tell, filtering words is not tracked in the log; even with the --debug flag. No other bots are running with this token.

I have done a number of tests on this and I can confirm without a shadow of a doubt that it will filter away my messages without a problem. Have you tested and had different results?

As far as I can tell, filtering words is not tracked in the log; even with the `--debug` flag. No other bots are running with this token. I have done a number of tests on this and I can confirm without a shadow of a doubt that it will filter away my messages without a problem. Have you tested and had different results?
mikeshardmind commented 2018-07-02 08:37:51 +02:00 (Migrated from github.com)

Well, something is seriously wrong.... I can confirm both the issue with the spacing and with the bot owner being considered for deletion.

Well, something is seriously wrong.... I can confirm both the issue with the spacing and with the bot owner being considered for deletion.
Crossedfall commented 2018-07-18 17:38:49 +02:00 (Migrated from github.com)

@mikeshardmind Update: In B17, I can confirm that the bot no longer removes owner messages. The filter is still broken unfortunately.

@mikeshardmind **Update:** In B17, I can confirm that the bot no longer removes owner messages. The filter is still broken unfortunately.
palmtree5 commented 2018-08-29 09:53:06 +02:00 (Migrated from github.com)

oh wait, I know exactly why bot owner messages are being considered for deletion

if user and user == await bot.is_owner(user): 
     return True

bot.is_owner returns a bool. Hence why bot owner messages are being considered for deletion. That's actually a really easy fix though as you really just need to drop user == from that.

The sentences issue results from the way it's added to the filter. Consider the following:

https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/redbot/cogs/filter/filter.py#L76-L87

Notice under the outermost else in the for loop here that no spaces are ever actually added back in when adding words in the sentence to tmp.

I'm gonna assign this to myself to do as both are simple fixes

oh wait, I know exactly why bot owner messages are being considered for deletion ```py if user and user == await bot.is_owner(user): return True ``` `bot.is_owner` returns a bool. Hence why bot owner messages are being considered for deletion. That's actually a really easy fix though as you really just need to drop `user == ` from that. The sentences issue results from the way it's added to the filter. Consider the following: https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/redbot/cogs/filter/filter.py#L76-L87 Notice under the outermost `else` in the `for` loop here that no spaces are ever actually added back in when adding words in the sentence to `tmp`. I'm gonna assign this to myself to do as both are simple fixes
Tobotimus commented 2018-09-04 04:55:50 +02:00 (Migrated from github.com)

Resolved by #2065.

Resolved by #2065.
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#1904
No description provided.