refactor: fix casing and add type hints

This commit is contained in:
Ryan 2025-02-05 17:23:51 -05:00
parent d63155d0fb
commit 94837f0e77
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
3 changed files with 8 additions and 8 deletions

View File

@ -34,7 +34,7 @@ class ArgumentParser:
await utils.reply(message, f"`{e}`")
def range_type(string, min=0, max=100):
def range_type(string: str, min=0, max=100):
try:
value = int(string)
except ValueError:

View File

@ -81,7 +81,7 @@ def messages_per_second(limit=500):
)
async def auto_count(channel_id):
async def auto_count(channel_id: int):
if (channel := await client.fetch_channel(channel_id)) and isinstance(
channel, disnake.TextChannel
):

View File

@ -10,11 +10,11 @@ CATEGORY_NAMES = {
}
async def get_segments(videoId: str):
if videoId in sponsorblock_cache:
return sponsorblock_cache[videoId]
async def get_segments(video_id: str):
if video_id in sponsorblock_cache:
return sponsorblock_cache[video_id]
hashPrefix = hashlib.sha256(videoId.encode()).hexdigest()[:4]
hashPrefix = hashlib.sha256(video_id.encode()).hexdigest()[:4]
session = aiohttp.ClientSession()
response = await session.get(
f"https://sponsor.ajay.app/api/skipSegments/{hashPrefix}",
@ -22,8 +22,8 @@ async def get_segments(videoId: str):
)
if response.status == 200 and (
results := list(
filter(lambda v: videoId == v["videoID"], await response.json())
filter(lambda v: video_id == v["videoID"], await response.json())
)
):
sponsorblock_cache[videoId] = results[0]
sponsorblock_cache[video_id] = results[0]
return results[0]