aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-07-16 15:06:09 -0700
committerGravatar MarkKoz <[email protected]>2019-07-16 15:06:09 -0700
commitf4140471a936537aa67ddb9184b2d52bdd9e4114 (patch)
tree54b1830d27612a4ffc63d135e05f57f527ebf677
parentMerge remote-tracking branch 'origin/django' into django-merge (diff)
parentWhitelisting the kivy discord server from our filters (diff)
Merge remote-tracking branch 'origin/master' into django-merge
Merge user-event whitelists and special character support for off topic names.
-rw-r--r--bot/cogs/antispam.py9
-rw-r--r--bot/cogs/off_topic_names.py12
-rw-r--r--bot/constants.py1
-rw-r--r--config-default.yml2
4 files changed, 11 insertions, 13 deletions
diff --git a/bot/cogs/antispam.py b/bot/cogs/antispam.py
index eb3a75703..0c6a02bf9 100644
--- a/bot/cogs/antispam.py
+++ b/bot/cogs/antispam.py
@@ -10,7 +10,7 @@ from bot.cogs.moderation import Moderation
from bot.cogs.modlog import ModLog
from bot.constants import (
AntiSpam as AntiSpamConfig, Channels,
- Colours, DEBUG_MODE, Event,
+ Colours, DEBUG_MODE, Event, Filter,
Guild as GuildConfig, Icons,
Roles, STAFF_ROLES,
)
@@ -30,11 +30,6 @@ RULE_FUNCTION_MAPPING = {
'newlines': rules.apply_newlines,
'role_mentions': rules.apply_role_mentions
}
-WHITELISTED_CHANNELS = (
- Channels.admins, Channels.announcements, Channels.big_brother_logs,
- Channels.devlog, Channels.devtest, Channels.helpers, Channels.message_log,
- Channels.mod_alerts, Channels.modlog, Channels.staff_lounge
-)
class AntiSpam:
@@ -55,7 +50,7 @@ class AntiSpam:
not message.guild
or message.guild.id != GuildConfig.id
or message.author.bot
- or (message.channel.id in WHITELISTED_CHANNELS and not DEBUG_MODE)
+ or (message.channel.id in Filter.channel_whitelist and not DEBUG_MODE)
or (any(role.id in STAFF_ROLES for role in message.author.roles) and not DEBUG_MODE)
):
return
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py
index fd90bb0c8..c0d2e5dc5 100644
--- a/bot/cogs/off_topic_names.py
+++ b/bot/cogs/off_topic_names.py
@@ -19,7 +19,7 @@ class OffTopicName(Converter):
@staticmethod
async def convert(ctx: Context, argument: str):
- allowed_characters = ("-", "โ€™", "'", "`")
+ allowed_characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?'`-"
if not (2 <= len(argument) <= 96):
raise BadArgument("Channel name must be between 2 and 96 chars long")
@@ -30,11 +30,11 @@ class OffTopicName(Converter):
"alphanumeric characters, minus signs or apostrophes."
)
- elif not argument.islower():
- raise BadArgument("Channel name must be lowercase")
-
- # Replace some unusable apostrophe-like characters with "โ€™".
- return argument.replace("'", "โ€™").replace("`", "โ€™")
+ # Replace invalid characters with unicode alternatives.
+ table = str.maketrans(
+ allowed_characters, '๐– ๐–ก๐–ข๐–ฃ๐–ค๐–ฅ๐–ฆ๐–ง๐–จ๐–ฉ๐–ช๐–ซ๐–ฌ๐–ญ๐–ฎ๐–ฏ๐–ฐ๐–ฑ๐–ฒ๐–ณ๐–ด๐–ต๐–ถ๐–ท๐–ธ๐–นวƒ๏ผŸโ€™โ€™-'
+ )
+ return argument.translate(table)
async def update_names(bot: Bot, headers: dict):
diff --git a/bot/constants.py b/bot/constants.py
index 033d19f7b..ead26c91d 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -352,6 +352,7 @@ class Channels(metaclass=YAMLGetter):
reddit: int
talent_pool: int
userlog: int
+ user_event_a: int
verification: int
diff --git a/config-default.yml b/config-default.yml
index dd5126230..2f5dcf5dc 100644
--- a/config-default.yml
+++ b/config-default.yml
@@ -115,6 +115,7 @@ guild:
staff_lounge: &STAFF_LOUNGE 464905259261755392
talent_pool: &TALENT_POOL 534321732593647616
userlog: 528976905546760203
+ user_event_a: &USER_EVENT_A 592000283102674944
verification: 352442727016693763
ignored: [*ADMINS, *MESSAGE_LOG, *MODLOG]
@@ -215,6 +216,7 @@ filter:
- *STAFF_LOUNGE
- *DEVTEST
- *TALENT_POOL
+ - *USER_EVENT_A
role_whitelist:
- *ADMIN_ROLE