Skip to content

Instantly share code, notes, and snippets.

@markis
Last active September 4, 2019 00:52
Show Gist options
  • Save markis/48a71a0fbe71a3996cf8167e48b0bcc9 to your computer and use it in GitHub Desktop.
Save markis/48a71a0fbe71a3996cf8167e48b0bcc9 to your computer and use it in GitHub Desktop.
Simplest example of creating chat post using praw
from praw import Reddit
# Get a Reddit instance
# https://praw.readthedocs.io/en/latest/code_overview/reddit_instance.html#
reddit = Reddit(
client_id="<client_id>",
client_secret="<client_secret>",
username="<user>",
password="<password>",
user_agent="Script by /u/markis",
)
# Make direct post against the API
# https://praw.readthedocs.io/en/latest/code_overview/reddit_instance.html#praw.Reddit.post
reddit.post('api/submit/', data={
"sr": "<subreddit_name>",
"kind": "self",
"resubmit": True,
"sendreplies": True,
"title": "<post title>",
"text": "<post text>",
"nsfw": False,
"spoiler": False,
# This will make the post a chat-post
"discussion_type": "CHAT",
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment