diff options
author | 2023-03-30 16:16:43 -0400 | |
---|---|---|
committer | 2023-03-31 21:43:12 +0300 | |
commit | 729f2288dd48208bae7af5d22136921ec30f21b3 (patch) | |
tree | de9e51b5c7b4100530016f9e4744abb379326c59 | |
parent | Change "Help!" to "answer this!" (diff) |
Use broader heuristic for detecting questions.
Namely just seeing if there's a question mark in it that isn't part of a URL.
-rw-r--r-- | bot/exts/recruitment/helper_utils.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/bot/exts/recruitment/helper_utils.py b/bot/exts/recruitment/helper_utils.py index df7260c40..3ea8108f6 100644 --- a/bot/exts/recruitment/helper_utils.py +++ b/bot/exts/recruitment/helper_utils.py @@ -1,5 +1,6 @@ import datetime as dt import random +import re from async_rediscache import RedisCache from discord import Message @@ -14,6 +15,8 @@ NEW_HELPER_ROLE_ID = Roles.new_helpers log = get_logger(__name__) +URL_RE = re.compile(r"(https?://[^\s]+)", flags=re.IGNORECASE) + class NewHelperUtils(Cog): """Manages functionality for new helpers in April 2023.""" @@ -36,19 +39,7 @@ class NewHelperUtils(Cog): @staticmethod def _is_question(message: str) -> bool: """Return True if `message` appears to be a question, else False!""" - return ( - ('?' in message) - and any(map( - message.lower().startswith, - ( - 'is', 'are', 'am', - 'was', 'were', - 'will', - 'can', 'does', 'do', 'did' - 'who', 'what', 'when', 'where', 'why' - ) - )) - ) + return '?' in URL_RE.sub('', message) @Cog.listener() async def on_message(self, message: Message) -> None: |