Skip to content

Commit

Permalink
[Welcome] 2.5.3 Fix an issue with filtering names on 3.5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
TrustyJAID committed Jul 11, 2024
1 parent b4e73d4 commit dfaa29d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TrustyJAID's Cogs for [Red-DiscordBot](https://github.com/Cog-Creators/Red-Disc
| Tweets | 3.0.1 | <details><summary>Cog for getting info from Twitter</summary>Gets the latest Tweet from twitter accounts and posts them in the specified channels</details> | palmtree5 and TrustyJAID |
| Twitch | 1.4.0 | <details><summary>Get basic twitch account information.</summary>Get notified of new twitch followers and get basic profile info.</details> | TrustyJAID |
| Weather | 1.5.0 | <details><summary>Show the current weather in specified locations!</summary>Check the current weather in many cities around the world including in Kelvin.</details> | TrustyJAID |
| Welcome | 2.5.2 | <details><summary>Welcome new users to the server</summary>Welcome new users to the server or say goodbye when they leave.</details> | irdumb and TrustyJAID |
| Welcome | 2.5.3 | <details><summary>Welcome new users to the server</summary>Welcome new users to the server or say goodbye when they leave.</details> | irdumb and TrustyJAID |

Any questions you can find [TrustyBot](https://discordapp.com/api/oauth2/authorize?client_id=268562382173765643&permissions=2146958583&scope=bot) and myself over on [my server](https://discord.gg/wVVrqej) or on the [Redbot Cog Support server](https://discord.gg/GET4DVk).
## Credits
Expand Down
22 changes: 17 additions & 5 deletions welcome/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import discord
from red_commons.logging import getLogger
from redbot import VersionInfo, version_info
from redbot.core import Config, commands
from redbot.core.bot import Red
from redbot.core.i18n import Translator, cog_i18n
Expand Down Expand Up @@ -68,7 +69,10 @@ async def convert_parms(
param = params[0]
raw_response = raw_response.replace("{" + result[0] + "}", param)
if has_filter:
bad_name = await has_filter.filter_hits(username, guild)
if version_info < VersionInfo.from_str("3.5.10"):
bad_name = await has_filter.filter_hits(username, guild)
else:
bad_name = await has_filter.filter_hits(guild, username)
if bad_name:
for word in bad_name:
raw_response = re.sub(rf"(?i){word}", filter_setting, raw_response)
Expand Down Expand Up @@ -99,7 +103,10 @@ async def make_embed(
username = str(member)
if has_filter:
replace_word = await self.config.guild(guild).FILTER_SETTING() or "[Redacted]"
bad_words = await has_filter.filter_hits(username, guild)
if version_info < VersionInfo.from_str("3.5.10"):
bad_words = await has_filter.filter_hits(username, guild)
else:
bad_words = await has_filter.filter_hits(guild, username)
if bad_words:
for word in bad_words:
username = username.replace(word, replace_word)
Expand Down Expand Up @@ -171,9 +178,14 @@ async def on_member_join(self, member: discord.Member) -> None:
has_filter = self.bot.get_cog("Filter")
filter_setting = await self.config.guild(guild).FILTER_SETTING()
if has_filter and filter_setting is None:
if await has_filter.filter_hits(member.name, guild):
log.info("Member joined with a bad username.")
return
if version_info < VersionInfo.from_str("3.5.10"):
if await has_filter.filter_hits(member.name, guild):
log.info("Member joined with a bad username.")
return
else:
if await has_filter.filter_hits(guild, member.name):
log.info("Member joined with a bad username.")
return

if datetime.now(timezone.utc).date() > self.today_count["now"].date():
self.today_count = {"now": datetime.now(timezone.utc)}
Expand Down
2 changes: 1 addition & 1 deletion welcome/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Welcome(Events, commands.Cog):
https://github.com/irdumbs/Dumb-Cogs/blob/master/welcome/welcome.py"""

__author__ = ["irdumb", "TrustyJAID"]
__version__ = "2.5.2"
__version__ = "2.5.3"

def __init__(self, bot):
self.bot = bot
Expand Down

0 comments on commit dfaa29d

Please sign in to comment.