Reddit Admin
Plugin-based, extensible administrative Reddit bot framework capable of managing and running multiple 'plugins' (i.e. scripts) asynchronously. Built on top of the PRAW API client wrapper.
It includes a working implementation of the bot itself and tools to build plugins for the bot to run.
Installation
pip install redditadmin
For instructions on installing Python and pip see "The Hitchhiker's Guide to Python"
Installation Guides.
Quickstart
reddit-admin requires two things in order for it to work:
- Valid OAuth script application credentials i.e.
client_id,client_secret,username,passwordanduser_agent(see more about that here) - A list of plugins (will discuss more about how to implement these later)
Assuming that both of these are provided for, the bot may be run in this way:
from redditadmin import get_reddit_admin, BotCredentials
# Enter the OAuth credentials into the BotCredentials constructor
bot_credentials = BotCredentials(
client_id="example_id",
client_secret="example_secret",
user_agent="example_useragent",
username="example_username",
password="example_password"
)
# List of plugins provided by the user
plugins = [plugin1, plugin2, ...]
# Built-in function to get an instance of the reddit-admin bot
reddit_admin = get_reddit_admin(
plugins=plugins
)
# Running the bot
reddit_admin.run(
bot_credentials=bot_credentials,
listen=False # (Default value)
)
NOTE: RedditAdmin.run() is a blocking command, meaning that no further code will execute until either the RedditAdmin.stop() function is called elsewhere, or if the bot receives a SIGINT or SIGTERM signal.
Console output:
redditadmin.core : Initializing the bot
Asynchronous Plugins Executor : Initializing Plugins Executor
Asynchronous Plugins Executor : Retrieving initial program commands
Asynchronous Plugins Executor : Executing initial program commands
Asynchronous Plugins Executor : Running program 'plugin1_program'
Asynchronous Plugins Executor : Running program 'plugin2_program'
Asynchronous Plugins Executor : Programs Executor initialized
redditadmin.core : Bot successfully initialized
redditadmin.core : The bot is now running
Bot modes
The bot runs in two modes: 'listening' mode and 'autonomous' mode. In listening mode, the bot is capable of receiving commands through the console input, while in autonomous mode, the bot only responds to system signals (e.g. SIGINT).
Listening mode bot commands:
status- displays the status of running plugin programsrun- runs a plugin program (provided one is not already running)shutdown/quit/exit- shuts down the bot
Plugins
Plugins are mini-applications run and managed by Reddit Admin which instantiate a specific task or program.
The redditadminplugins Python package contains some useful plugins which may be adapted to the user's needs (see more here).
To create a custom plugin, you need to do 2 things:
- To implement a
Program - To implement a
Pluginbased on the implemented program
For example, we may create a plugin which automatically posts a submission to the r/test subreddit when run as follows:
Program:
from redditadmin import Plugin, Program, get_reddit_admin
class MyProgram[Program]:
"""The program to post our submission"""
def __init__(praw_reddit):
super().__init__("My Program")
self.praw_reddit = praw_reddit
def execute(self, *args, **kwargs):
"""Overriden from the Program superclass"""
self.praw_reddit.subreddit('test').submit(
title="Testing 123",
url="https://google.com"
)
Plugin:
class MyPlugin[Plugin[MyProgram]]
"""The plugin for our program"""
def __init__():
super().__init__("myprogram")
def get_program(self, reddit_interface):
"""Overriden from Plugin superclass"""
praw_reddit = reddit_interface.praw_reddit
return MyProgram(praw_reddit)
Voila! We may now supply our plugin to the bot and run it just as we did before
plugin = MyPlugin()
bot_credentials = ...
reddit_admin = get_reddit_admin(
plugins=[plugin]
)
reddit_admin.run(
bot_credentials=bot_credentials
)
For more information on how to use PRAW in your plugins, see the official repository here.
See more
Metadata
Release files for redditadmin 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| redditadmin-0.1.7.tar.gz | 19.7 kB | Without provenance | Details for redditadmin-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| redditadmin-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for redditadmin-0.1.7-py3-none-any.whl |
Total release size: 45.9 kB
Release files / redditadmin-0.1.7.tar.gz
| Download URL | redditadmin-0.1.7.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7f080e23578100a62cedb82cca5da3b52ab50c25f257502641351dcabd264a1
|
|
BLAKE2b-256 checksum How to use checksums |
0a9d0ef0a7b8168d73e2f211af835471addd7bf15e3ed2e329d25a1705df2d61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Release files / redditadmin-0.1.7-py3-none-any.whl
| Download URL | redditadmin-0.1.7-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e6013fb024e506d52c75ba0992960d5e376084683541c998aabf1d8499d6e0e
|
|
BLAKE2b-256 checksum How to use checksums |
1ba0f76bd734dac5ea82d09c8b6207bc6ff06a22006582c0f94adacd4a9e7ba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Security for redditadmin 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.