28 lines
789 B
Python
28 lines
789 B
Python
import logging
|
|
|
|
import praw
|
|
from praw.models import Submission
|
|
|
|
from .config import CONFIG
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
praw = praw.Reddit(**CONFIG["reddit"])
|
|
|
|
|
|
def send_pm(recipient, title, text) -> None:
|
|
logger.info("Sending PM to u/%s", recipient)
|
|
return praw.redditor(recipient).message(title, text)
|
|
|
|
|
|
def submit_post(title, text, subreddit) -> Submission:
|
|
logger.info("Submitting post to r/%s", subreddit)
|
|
return praw.subreddit(subreddit).submit(title, text)
|
|
|
|
|
|
def get_previous_daily_post(subreddit) -> Submission:
|
|
logger.info("Getting previous daily post from r/%s", subreddit)
|
|
return next(praw.subreddit(subreddit).search('title:"daily releases"', sort="new", syntax="lucene",
|
|
time_filter="week"))
|