migrated to asyncPRAW (i fucking hate it but it made reddit shut the fuck up)

This commit is contained in:
2025-02-12 17:43:35 +01:00
parent 67052b1511
commit 069d615272
14 changed files with 121 additions and 130 deletions
+27 -15
View File
@@ -1,30 +1,42 @@
from io import TextIOWrapper
from praw import models
import praw
import asyncpraw as praw
import os
from macros import *
class Bot:
args: dict = {"NO_RUST": True, "dev": True, "py": True, "port": 2920}
password: str = os.environ.get("ASSISTANT_R_PASS")
secret: str = os.environ.get("ASSISTANT_R_TOKEN")
secret: str = os.environ.get("ASSISTANT_R_TOKEN")
if password is None:
py_error("Environment variable \"ASSISTANT_R_PASS\" is null!")
if secret is None:
py_error("Environment variable \"ASSISTANT_R_TOKEN\" is null!")
r: praw.Reddit = praw.Reddit(
client_id = "iCSRWS6PMlTLwmylCJRYmA",
client_secret = secret,
username = "ByteDiceAssistant",
password = password,
user_agent = "Byte Dice Assistant by u/RandomPersonDotExe aka u/Byte_Dice"
)
sr: models.Subreddit = r.subreddit("bytedicetesting") #r.subreddit("boykisser")
data_f: TextIOWrapper = None
data: dict = {}
def __init__(self):
self.r: praw.Reddit = praw.Reddit(
client_id="iCSRWS6PMlTLwmylCJRYmA",
client_secret=self.secret,
username="ByteDiceAssistant",
password=self.password,
user_agent="Byte Dice Assistant by u/RandomPersonDotExe aka u/Byte_Dice"
)
self.sr = None
self.data_f: TextIOWrapper = None
self.data: dict = {}
def set_args(self, args: dict):
self.args = args
async def initialize(self):
self.sr = await self.r.subreddit("bytedicetesting")#boykisser")
async def set_args(self, args: dict):
self.args = args
async def stop(self) -> bool:
if self.r:
await self.r.close()
py_print("Stopped Reddit bot.")
return True
return False