diff options
-rw-r--r-- | markov/info.json | 2 | ||||
-rw-r--r-- | markov/markov.py | 1 | ||||
-rw-r--r-- | question_of_the_day/question_of_the_day.py | 2 | ||||
-rw-r--r-- | wplink/__init__.py | 5 | ||||
-rw-r--r-- | wplink/info.json | 4 | ||||
-rw-r--r-- | wplink/wplink.py | 53 |
6 files changed, 2 insertions, 65 deletions
diff --git a/markov/info.json b/markov/info.json index 6002815..22ddb18 100644 --- a/markov/info.json +++ b/markov/info.json @@ -2,5 +2,5 @@ "author": ["Arjun Satarkar"], "description": "Use Markov chains to mimic users or the server as a whole.", "short": "Markov chains based on message content.", - "requirements": ["aiosqlite", "more-itertools"] + "requirements": ["aiosqlite"] } diff --git a/markov/markov.py b/markov/markov.py index 9965d65..c756d2c 100644 --- a/markov/markov.py +++ b/markov/markov.py @@ -4,7 +4,6 @@ import redbot.core from redbot.core import Config from redbot.core import commands import enum -import math import random import re import unicodedata diff --git a/question_of_the_day/question_of_the_day.py b/question_of_the_day/question_of_the_day.py index b812e81..42fb9b2 100644 --- a/question_of_the_day/question_of_the_day.py +++ b/question_of_the_day/question_of_the_day.py @@ -374,7 +374,7 @@ class QuestionOfTheDay(commands.Cog): await self.config.guild(guild).suggested_questions() ) footer += ( - f"{suggestions_count} suggestion{'s' if suggestions_count > 1 else ''}" + f"{suggestions_count} suggestion{'' if suggestions_count == 1 else 's'}" if suggestions_count else "no suggestions yet! use qotd suggest" ) diff --git a/wplink/__init__.py b/wplink/__init__.py deleted file mode 100644 index f82c406..0000000 --- a/wplink/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .wplink import WPLink - - -async def setup(bot): - await bot.add_cog(WPLink(bot)) diff --git a/wplink/info.json b/wplink/info.json deleted file mode 100644 index 297e4e0..0000000 --- a/wplink/info.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "author": ["Arjun Satarkar"], - "requirements": ["aiohttp", "async-lru"] -} diff --git a/wplink/wplink.py b/wplink/wplink.py deleted file mode 100644 index 1da38ff..0000000 --- a/wplink/wplink.py +++ /dev/null @@ -1,53 +0,0 @@ -import aiohttp -import async_lru -import discord -from redbot.core import commands -import logging -import re -import urllib.parse - - -class WPLink(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.logger = logging.getLogger("red.aps-cogs.wplink") - - @commands.Cog.listener() - async def on_message(self, message: discord.Message): - WIKILINK_PATTERN = r"\[\[(.+?)\]\]" - MAX_LINKS_PER_MESSAGE = 6 - # Per https://www.mediawiki.org/wiki/Page_title_size_limitations - MAX_TITLE_LEN = 255 - - titles = re.findall(WIKILINK_PATTERN, message.content) - titles = titles[:MAX_LINKS_PER_MESSAGE] - - formatted_page_urls = [] - for title in titles: - if len(title) > MAX_TITLE_LEN: - continue - page_url = await self.look_up_page(title) - if page_url is not None: - formatted_page_urls.append(f"<{page_url}>") - - if formatted_page_urls: - await message.reply( - ", ".join(formatted_page_urls), - allowed_mentions=discord.AllowedMentions.none(), - ) - - @async_lru.alru_cache(maxsize=512) - async def look_up_page(self, title: str) -> str | None: - self.logger.info("Looking up page title %s", title) - MAX_URL_SIZE = 400 - query_url = f"https://en.wikipedia.org/wiki/Special:Search?search={urllib.parse.quote(title)}&go=Go" - async with aiohttp.ClientSession() as session: - async with session.head(query_url, allow_redirects=True) as response: - if response.status != 200: - return None - result_url = str(response.url) - if len(result_url) > MAX_URL_SIZE or result_url.startswith( - "https://en.wikipedia.org/wiki/Special:Search?" - ): - return None - return result_url |