Skip to content

Commit

Permalink
fix yelling types and remove arbitrary web request (#177)
Browse files Browse the repository at this point in the history
* fix yelling types and remove arbitrary web request

* style. also take 2

* of all the days for my typechecker to stop fucking working

* i'm capitulating

* fixed capitulation
  • Loading branch information
andrewj-brown authored Nov 8, 2023
1 parent c304268 commit 5f630cd
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions uqcsbot/yelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from discord.ext import commands
from random import choice, random
import re
from urllib.request import urlopen
from urllib.error import URLError

from uqcsbot.bot import UQCSBot
from uqcsbot.cog import UQCSBotCog
Expand Down Expand Up @@ -48,7 +46,8 @@ async def wrapper(
if not Yelling.contains_lowercase(text):
await func(cogself, *args, **kwargs)
return
await interaction.response.send_message(

await interaction.response.send_message( # type: ignore
str(discord.utils.get(bot.emojis, name="disapproval") or "")
)
if isinstance(interaction.user, discord.Member):
Expand Down Expand Up @@ -167,12 +166,6 @@ def clean_text(self, message: str) -> str:

# slightly more permissive version of discord's url regex, matches absolutely anything between http(s):// and whitespace
for url in re.findall(r"https?:\/\/[^\s]+", text, flags=re.UNICODE):
try:
resp = urlopen(url)
except (ValueError, URLError):
continue
if 400 <= resp.code <= 499:
continue
text = text.replace(url, url.upper())

text = text.replace("&gt;", ">").replace("&lt;", "<").replace("&amp;", "&")
Expand Down

0 comments on commit 5f630cd

Please sign in to comment.