1
0
Fork 0
This repository has been archived on 2023-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
dailyreleases/dailyreleases/reddit.py
2019-04-15 15:14:37 +02:00

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"))