Merge branch 'release-v0.5' into 'main' #3

Merged
official-Cromatin merged 17 commits from release-v0.5 into main 2025-09-16 18:49:29 +02:00
2 changed files with 7 additions and 8 deletions
Showing only changes of commit 96b001522f - Show all commits
+1 -1
View File
@@ -1,5 +1,5 @@
discord.py==2.4.0
praw==7.8.1
asyncpraw==7.8.1
colorama==0.4.6
aiohttp==3.11.11
pillow==11.1.0
+6 -7
View File
@@ -1,13 +1,12 @@
import praw
import praw.models
import asyncpraw
import asyncpraw.models
import logging
from utils.event_counter import Event_Counter
from utils.datetime_tools import get_elapsed_time_milliseconds
from typing import Union
from datetime import datetime
class Reddit_Adapter(praw.Reddit):
"""A class that extends and abstracts the functionality of the `praw.Reddit` class by adding
class Reddit_Adapter(asyncpraw.Reddit):
"""A class that extends and abstracts the functionality of the `asyncpraw.Reddit` class by adding
logging and request tracking capabilities."""
VERSION = "1.0"
number_of_instances = 0
@@ -25,11 +24,11 @@ class Reddit_Adapter(praw.Reddit):
self.__events = Event_Counter(1000)
self.__logger = logging.getLogger(f"pltfm.reddit.{self.__instance_number}")
def fetch(self, post_url:str) -> praw.models.Submission:
async def fetch(self, post_url:str) -> asyncpraw.models.Submission:
"""Fetches specified submission (post) and returns it"""
start_time = datetime.now().timestamp()
self.__events.increment()
subm = self.submission(url = post_url)
subm = await self.submission(url = post_url)
self.__logger.debug(f"Submission for post (URL: {post_url}), successfully fetched after {get_elapsed_time_milliseconds(datetime.now().timestamp() - start_time)}")
return subm