From 8b6ae0eea618e64b04aa1ec67969059443e3ec65 Mon Sep 17 00:00:00 2001 From: JelNiSlaw Date: Mon, 19 Jun 2023 14:09:43 +0200 Subject: [PATCH] add /kiedy-ios command --- wulkabot/cogs/automod.py | 8 +++++++- wulkabot/cogs/github.py | 1 - wulkabot/utils/github.py | 4 +--- wulkabot/utils/text_utils.py | 33 --------------------------------- 4 files changed, 8 insertions(+), 38 deletions(-) delete mode 100644 wulkabot/utils/text_utils.py diff --git a/wulkabot/cogs/automod.py b/wulkabot/cogs/automod.py index c519597..2637a99 100644 --- a/wulkabot/cogs/automod.py +++ b/wulkabot/cogs/automod.py @@ -1,4 +1,5 @@ import discord +from discord import app_commands from discord.ext import commands from .. import bot @@ -45,7 +46,7 @@ def is_ios_request(text: str, /) -> bool: # the text is longer and doesn't look like just a simple question return False - words = set(text.replace("?", "").replace("!", "").casefold().split()) + words = text.replace("?", "").replace("!", "").casefold().split() if all(word not in words for word in ("ios", "iphone", "apple")): return False @@ -64,6 +65,11 @@ class Automod(commands.Cog): reply = await message.reply(embed=IOS_NOTICE, view=view) view.message = reply + @app_commands.command(name="kiedy-ios") + async def kiedy_ios(self, interaction: discord.Interaction): + """Tłumaczy powody braku wersji na iOS""" + await interaction.response.send_message(embed=IOS_NOTICE) + async def setup(bot: bot.Wulkabot): await bot.add_cog(Automod()) diff --git a/wulkabot/cogs/github.py b/wulkabot/cogs/github.py index 479e204..b33c717 100644 --- a/wulkabot/cogs/github.py +++ b/wulkabot/cogs/github.py @@ -188,7 +188,6 @@ class GitHub(commands.Cog): view = DeleteButton(message.author) reply = await message.reply(embeds=embeds[:3], view=view) view.message = reply - print(reply.embeds) async def setup(bot: bot.Wulkabot): diff --git a/wulkabot/utils/github.py b/wulkabot/utils/github.py index c67c843..4418832 100644 --- a/wulkabot/utils/github.py +++ b/wulkabot/utils/github.py @@ -5,9 +5,7 @@ import aiohttp class GitHub: def __init__(self) -> None: - self._http = aiohttp.ClientSession( - base_url="https://api.github.com", headers={"Accept": "application/vnd.github.v3+json"} - ) + self._http = aiohttp.ClientSession(base_url="https://api.github.com") async def fetch_repo(self, owner: str, repo: str) -> dict[str, Any]: response = await self._http.get(f"/repos/{owner}/{repo}") diff --git a/wulkabot/utils/text_utils.py b/wulkabot/utils/text_utils.py deleted file mode 100644 index 19b84b0..0000000 --- a/wulkabot/utils/text_utils.py +++ /dev/null @@ -1,33 +0,0 @@ -POLISH_DIACRITICS = { - "Ą": "A", - "Ć": "C", - "Ę": "E", - "Ł": "L", - "Ń": "N", - "Ó": "O", - "Ś": "S", - "Ź": "Z", - "Ż": "Z", - "ą": "a", - "ć": "c", - "ę": "e", - "ł": "l", - "ń": "n", - "ó": "o", - "ś": "s", - "ź": "z", - "ż": "z", -} - - -def remove_diacritics(text: str, /) -> str: - """ - Replaces Polish diacritics with their ASCII counterparts - - Żółć => Zolc - Źdźbło => Zdzblo - """ - for (diacritic, ascii) in POLISH_DIACRITICS.items(): - text = text.replace(diacritic, ascii) - - return text