Skip to content
Ka Hung Lee edited this page Sep 14, 2022 · 3 revisions

Welcome to the prawscripts wiki! (Under construction)

To install prawscripts simply run:

pip3 install prawscripts

As it requires PRAW to run, it will also install PRAW as a dependency.

As this time, there are only 12 working functions:

  • antibrigadingbanbot
  • checkbanstatus
  • checkcrosspostperms
  • checkprivate
  • checksharedsubs
  • checksubperms
  • getinstance
  • getmodmailcount
  • removefromdeleted
  • searchmessageinboxkeyword
  • searchnewestpost
  • widgetbuilder

All functions at this time if derived from their scripts currently listed under the scripts-library from r/ModGuide. (https://www.reddit.com/r/modguide/wiki/script-library/)

To get started after installment, you would need to create a config.txt file within a directory you wish you use prawscripts. The config.txt would work akin to a local .env file, which would store the information needed to run PRAW. The format is similar to that found in PRAW's documentation. The main difference is you don't need to format it with commas

config.txt (example)

client_id="CLIENT_ID"
client_secret="CLIENT_SECRET"
password="PASSWORD"
user_agent="USERAGENT"
username="USERNAME"

After the config.txt is set up, you can start using prawscripts. To run the functions, start up Python3 and import prawscripts namely the getinstance function:

import os
from prawscripts import getinstance

To get a PRAW instance like you would with PRAW, run:

reddit = getinstance(/path/to/your/config.txt)

From there, everything you can run PRAW like you would normally, PRAW is automatically called from getinstance. The purpose of prawscripts, however, is not to simply use PRAW, but to use established scripts that has already been written before to perform tasks or collect information.

To see what functions are available from Python3, you can simply import struct and run dir(prawscripts) after importing prawscripts:

import struct

dir(prawscripts)

This will list the functions currently available to prawscripts. You could run these functions like you would for any other Python functions. For example: checkbanstatus(instance, username)

Here are the list of functions (aside from getinstance) with their required inputs:

  • antibridgebandbot(instance)
  • checkbanstatus(instance)
  • checkcrosspostperms(instance)
  • checkprivate(instance)
  • checksharedsubs(instance)
  • checksubperms(instance)
  • getmodmailcount(instance)
  • removefromdeleted(instance, sub_name)
  • searchmessageinboxkeyword(instance, keyword)
  • searchnewestpost(instance, sub_name, num_post)
  • widgetbuilder(instance, sub_name, widget_title, background_color, header_color, subList)

Except for removefromdeleted and antibrigadebanbot which are ran as commands, the rest of the functions return either a list or an object.

  • checkbanstatus(instance) => list
  • checkcrosspostperms(instance) => list
  • checkprivate(instance, sub_list) => list
  • checksharedsubs(instance) => list
  • checksubperms(instance) => list
  • getmodmailcount(instance) => list
  • searchmessageinboxkeyword(instance, keyword) => list
  • searchnewestpost(instance, sub_name, num_post) => list
  • widgetbuilder(instance, sub_name, widget_title, background_color, header_color, subList) => object

To access these lists for viewing use variables and print them accordingly, example:

from prawscripts import checkbanstatus

sub_list = checkbanstatus(reddit, "some_user123")
print(sub_list)

To see a detailed documentation of each function you could run:

print(prawscripts.function.doc)

Where you replace function with the actual function name. This will also display the original script of which the function was written from.

Clone this wiki locally