Skip to content
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

[V3 Filter] Unable to filter sentences #1904

Closed
Crossedfall opened this issue Jun 30, 2018 · 8 comments
Closed

[V3 Filter] Unable to filter sentences #1904

Crossedfall opened this issue Jun 30, 2018 · 8 comments
Assignees
Labels
Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.

Comments

@Crossedfall
Copy link
Contributor

Crossedfall commented Jun 30, 2018

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

@mikeshardmind
Copy link
Contributor

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

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

# Bots and mods or superior are ignored from the filter
mod_or_superior = await is_mod_or_superior(self.bot, obj=author)
if mod_or_superior:
return

if user and user == await bot.is_owner(user):
return True
elif admin_role and discord.utils.get(user.roles, name=admin_role):
return True
elif mod_role and discord.utils.get(user.roles, name=mod_role):
return True
else:
return False

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
Copy link
Contributor Author

Crossedfall commented Jul 2, 2018

@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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@Kowlin Kowlin added the V3 label Jul 14, 2018
@Crossedfall
Copy link
Contributor Author

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

@Tobotimus Tobotimus added the Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing. label Aug 4, 2018
@palmtree5
Copy link
Member

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

@palmtree5 palmtree5 self-assigned this Aug 29, 2018
@palmtree5 palmtree5 added Status: In Progress There's a PR open to deal with this, or an org member is working on this internally and removed Status: Accepted We want this labels Aug 29, 2018
@Tobotimus
Copy link
Member

Resolved by #2065.

@Tobotimus Tobotimus removed the Status: In Progress There's a PR open to deal with this, or an org member is working on this internally label Sep 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
Projects
None yet
Development

No branches or pull requests

5 participants