This release is a pre-release and may not be stable for production use.
Banhammer.py
Banhammer.py is a framework that allows you to build your very own Banhammer! Banhammer pursues the goal of bringing subreddit moderation to your very own Discord server, by streaming any and all moderatable items to Discord channels and allowing users to then moderate the subreddit through a joint bot account using Reactions, there's no need to use Reddit's moderation interface anymore!
Table of Contents
Features
- Streaming new and reported posts to your Discord bot.
- Adding and handling reactions.
- Fetching reactions from subreddit wiki.
- Changing bot presence on Discord.
- Generating embeds and messages for items and actions.
Installation
Banhammer.py requires a release of Python 3.6 or newer. You can install Banhammer.py via pip:
pip install banhammer.py
Quick Example
Once the dependencies have been installed, the bot can be created. For that the general structure of a Discord Client or Bot (if commands are of importance use Bot) needs to be created and then Banhammer initialized as well as ran.
import apraw
import discord
import banhammer
from banhammer.models import Subreddit
from discord.ext import commands
bot = commands.Bot(command_prefix='>')
reddit = apraw.Reddit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET,
password=PASSWORD, username=USERNAME, user_agent=USER_AGENT)
bh = banhammer.Banhammer(reddit, bot=bot)
@bot.event
async def on_command_error(ctx, error):
print(error)
@bot.event
async def on_ready():
print(str(bot.user) + ' is running.')
sub = Subreddit(bh, SUBNAME)
await sub.load_reactions()
await bh.add_subreddits(sub)
bh.run()
@bh.new()
async def handle_new(p):
msg = await bot.get_channel(CHANNEL_ID).send(embed=await p.get_embed())
await p.add_reactions(m)
bot.run(TOKEN)
bh.run() must be called so that Banhammer can start the internal event loop. More examples can be found in the (examples)[examples] folder or in the Banhacker as well as the D6B GitHub repositories that both show different (and more complex) implementations of the framework.
Contributing
Banhammer.py is open-source! That means we'd love to see your contributions and hopefully be able to accept them in the next release. If you want to become a contributor, try to follow these rules to keep the code clean:
- Follow Python naming conventions. (eg.
variable_nameandClassName) - Only use
asyncwhere necessary. - Use the OOP approach; create classes when it makes sense.
- Document as much as you can, preferably with inline comments.
- Use the NumPyDoc docstring format.
- Store data in JSON, INI or YAML format to eliminate dependencies for other formats.
Roadmap
- Returning actions performed.
- Improved support for modmail.
-
MessageBuilderobject to create custom messages/embeds. -
save()function forSubredditobject. - Support for newer PRAW features (such as locking comments).
- Validation of inputs.
- Better exception handling and outputs.
- Support for variable function arguments.
Links
License
Banhammer.py's source is provided under GPLv3.
Copyright ©, RaviAnand Mohabir
Metadata
Release files for Banhammer.py 2.5.4b0
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 |
|---|---|---|---|---|
| Banhammer.py-2.5.4b0.tar.gz | 17.7 kB | Without provenance | Details for Banhammer.py-2.5.4b0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Banhammer.py-2.5.4b0-py3-none-any.whl | Python 3 | none | any | Details for Banhammer.py-2.5.4b0-py3-none-any.whl |
Total release size: 51.7 kB
Release files / Banhammer.py-2.5.4b0.tar.gz
| Download URL | Banhammer.py-2.5.4b0.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3385450f79da18c0acfb496a33dd0434d752a7df4effabacae560afbac35164
|
|
BLAKE2b-256 checksum How to use checksums |
addddb024c6aaed767780cd0be6e04261f9295e3100e6d4ff7524d05167577c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Release files / Banhammer.py-2.5.4b0-py3-none-any.whl
| Download URL | Banhammer.py-2.5.4b0-py3-none-any.whl |
|---|---|
| Size | 34.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f158ed35148a1e3bc6b6ad96e0f302eda984f2bee195558102fb49d84ebf441
|
|
BLAKE2b-256 checksum How to use checksums |
c0e2917fcfa51d4e023a508a1db24ccf477deeacfcff6ffdfe77c09da87c9b57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Security for Banhammer.py 2.5.4b0
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.