Skip to content

Commit

Permalink
updates to python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCataliasTNT2k committed Jul 20, 2023
1 parent 717abdf commit 9cad4b7
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 1,086 deletions.
2 changes: 1 addition & 1 deletion administration/sudo/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from PyDrocsid.environment import OWNER_ID
from PyDrocsid.events import call_event_handlers
from PyDrocsid.permission import permission_override
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.translations import t

from .permissions import SudoPermission
Expand Down
2 changes: 1 addition & 1 deletion general/custom_commands/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from PyDrocsid.embeds import send_long_embed
from PyDrocsid.logger import get_logger
from PyDrocsid.permission import BasePermissionLevel
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.translations import t
from PyDrocsid.util import check_message_send_permissions

Expand Down
2 changes: 1 addition & 1 deletion general/voice_channel/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from PyDrocsid.emojis import name_to_emoji
from PyDrocsid.multilock import MultiLock
from PyDrocsid.prefix import get_prefix
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.settings import RoleSettings
from PyDrocsid.translations import t
from PyDrocsid.util import check_role_assignable, send_editable_log
Expand Down
8 changes: 4 additions & 4 deletions integrations/adventofcode/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def load(cls) -> bool:
if not cls.SESSION:
return False

response = requests.get(BASE_URL + "leaderboard/private", cookies={"session": cls.SESSION})
response = requests.get(BASE_URL + "leaderboard/private", cookies={"session": cls.SESSION}, timeout=10)
if not response.ok or not response.url.endswith("private"):
return False

Expand All @@ -64,7 +64,7 @@ def load(cls) -> bool:

@classmethod
def _request(cls, url):
return requests.get(url, cookies={"session": cls.SESSION})
return requests.get(url, cookies={"session": cls.SESSION}, timeout=10)

@classmethod
async def get_leaderboard(cls, disable_hook: bool = False) -> dict:
Expand Down Expand Up @@ -177,10 +177,10 @@ def get_git_repo(url: str) -> Optional[str]:
if not (match := re.match(pattern, url)):
continue
_, user, repo, path = match.groups()
if not (response := requests.get(api.format(user=user, repo=repo))).ok:
if not (response := requests.get(api.format(user=user, repo=repo), timeout=10)).ok:
break
url = response.json()[web_url_key] + (path or "")
if not requests.head(url).ok:
if not requests.head(url, timeout=10).ok:
break
return url
return None
Expand Down
2 changes: 1 addition & 1 deletion integrations/python_docs/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from PyDrocsid.command import reply
from PyDrocsid.environment import CACHE_TTL
from PyDrocsid.logger import get_logger
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.translations import t

from .colors import Colors
Expand Down
10 changes: 5 additions & 5 deletions integrations/reddit/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Optional

from aiohttp import ClientSession
from discord import Embed, TextChannel
from discord import Embed, TextChannel, Thread
from discord.ext import commands, tasks
from discord.ext.commands import CommandError, Context, UserInputError, guild_only

Expand Down Expand Up @@ -115,7 +115,7 @@ async def pull_hot_posts(self):
logger.info("pulling hot reddit posts")
limit = await RedditSettings.limit.get()
async for reddit_channel in await db.stream(select(RedditChannel)): # type: RedditChannel
text_channel: Optional[TextChannel] = self.bot.get_channel(reddit_channel.channel)
text_channel: Optional[TextChannel | Thread] = self.bot.get_channel(reddit_channel.channel)
if text_channel is None:
await db.delete(reddit_channel)
continue
Expand Down Expand Up @@ -171,7 +171,7 @@ async def reddit(self, ctx: Context):

out = []
async for reddit_channel in await db.stream(select(RedditChannel)): # type: RedditChannel
text_channel: Optional[TextChannel] = self.bot.get_channel(reddit_channel.channel)
text_channel: Optional[TextChannel | Thread] = self.bot.get_channel(reddit_channel.channel)
if text_channel is None:
await db.delete(reddit_channel)
else:
Expand All @@ -183,7 +183,7 @@ async def reddit(self, ctx: Context):

@reddit.command(name="add", aliases=["a", "+"])
@RedditPermission.write.check
async def reddit_add(self, ctx: Context, subreddit: str, channel: TextChannel):
async def reddit_add(self, ctx: Context, subreddit: str, channel: TextChannel | Thread):
"""
create a link between a subreddit and a channel
"""
Expand All @@ -203,7 +203,7 @@ async def reddit_add(self, ctx: Context, subreddit: str, channel: TextChannel):

@reddit.command(name="remove", aliases=["r", "del", "d", "-"])
@RedditPermission.write.check
async def reddit_remove(self, ctx: Context, subreddit: str, channel: TextChannel):
async def reddit_remove(self, ctx: Context, subreddit: str, channel: TextChannel | Thread):
"""
remove a reddit link
"""
Expand Down
2 changes: 1 addition & 1 deletion moderation/autorole/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from PyDrocsid.async_thread import lock_deco
from PyDrocsid.database import Base, db, delete, select
from PyDrocsid.environment import CACHE_TTL
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis


@lock_deco
Expand Down
2 changes: 1 addition & 1 deletion moderation/content_filter/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from PyDrocsid.emojis import name_to_emoji
from PyDrocsid.environment import CACHE_TTL
from PyDrocsid.events import StopEventHandling
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.translations import t

from .colors import Colors
Expand Down
2 changes: 1 addition & 1 deletion moderation/content_filter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from PyDrocsid.database import Base, UTCDateTime, db, select
from PyDrocsid.environment import CACHE_TTL
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis


async def sync_redis() -> list[str]:
Expand Down
2 changes: 1 addition & 1 deletion moderation/logging/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from PyDrocsid.embeds import send_long_embed
from PyDrocsid.environment import CACHE_TTL
from PyDrocsid.logger import get_logger
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.translations import t
from PyDrocsid.util import calculate_edit_distance, check_message_send_permissions

Expand Down
2 changes: 1 addition & 1 deletion moderation/mediaonly/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from PyDrocsid.database import Base, UTCDateTime, db, delete, filter_by, select
from PyDrocsid.environment import CACHE_TTL
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis


class MediaOnlyChannel(Base):
Expand Down
2 changes: 1 addition & 1 deletion moderation/spam_detection/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from PyDrocsid.cog import Cog
from PyDrocsid.command import CommandError, docs, reply
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.translations import t

from .colors import Colors
Expand Down
2 changes: 1 addition & 1 deletion moderation/threads/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from PyDrocsid.cog import Cog
from PyDrocsid.command import docs
from PyDrocsid.embeds import send_long_embed
from PyDrocsid.redis import redis
from PyDrocsid.redis_client import redis
from PyDrocsid.settings import RoleSettings
from PyDrocsid.translations import t

Expand Down
Loading

0 comments on commit 9cad4b7

Please sign in to comment.