Pyredditchatbot
Pyredditchatbot is a Python package for easily building reddit chatbots that surf your favourite subreddit and replies when called. Simply modify the parameters mentioned in the Quickstart to create your own custom reddit chatbot to add some life to your subreddit!
Installation
Pyredditchatbot is supported on Python 3.7 and above. The recommended way to install it is via pip <https://pypi.python.org/pypi/pip>.
pip install pyredditchatbot
For instructions on installing Python and pip see "The Hitchhiker's Guide to Python"
Installation Guides <https://docs.python-guide.org/en/latest/starting/installation/>.
Quickstart
Go to https://www.reddit.com/prefs/apps/ and login with your reddit account. This is the account that will be replying, so consider making a new account if you're looking to roleplay as a character. Please also make sure to read reddit etiquette and guidelines before creating a bot.
Create a script type application by filling out the form. You should now have a client id and secret for the application just created.
You can create a bot like so:
import pyredditchatbot as prc
bot = prc.Bot(
client_id,
client_secret,
reddit_username,
reddit_password,
"u/my-bot",
"my-favourite-subreddit"
)
The bot surfs all the comments on the subreddit my-favourite-subreddit
and replies whenever it sees the phrase u/my-bot in a comment.
You need to add quotes to your bot to help it choose what to reply with. By default it looks for quotes.txt locally.
You can also add your quotes as an iterable like this:
quotes = ["Hi", "How are you!!", "Hello!"]
bot.add_quotes(quotes)
You can also fetch quotes directly from a file:
bot.add_quotes_file("path/to/file/quotes.txt")
Each new line in the file is considered as a new quote.
If you want to pre_process the quotes, you can pass your custom callable like so:
bot = prc.Bot(
client_id,
client_secret,
username,
password,
"u/my-bot",
"my-favourite-subreddit"
quote_cleaner=my_pre_processor_func
)
This will call my_pre_processor_func(quotes) and add the output to the bot instance.
If no quote_cleaner is passed, a default cleaner which simple removes empty quotes is used.
To run the bot, simply do:
bot.run()
This will run the bot continuously until the script is terminated.
If the bot is run without any quotes and a local quotes.txt
doesn't exist, the run fails with a QuotesNotFoundError.
License
Pyredditchatbot is provided under the Simplified BSD License
Release files for pyredditchatbot 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyredditchatbot-0.1.3.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyredditchatbot-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.7 kB
Release files / pyredditchatbot-0.1.3.tar.gz
| Download URL | pyredditchatbot-0.1.3.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a38e3bc374f3777da560060e604bb4de7c5d94e312bd76e1d2cc170bdbe8916
|
|
BLAKE2b-256 checksum How to use checksums |
33952b9634988a8bc4855189aa5d2d8560797da369271fb448d1b310d964d406
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / pyredditchatbot-0.1.3-py3-none-any.whl
| Download URL | pyredditchatbot-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9335bbc2fd53044c6cda39fe5cf7afdda5a58a0adb10da4818de789c8ff921a2
|
|
BLAKE2b-256 checksum How to use checksums |
a03e00b09516d09ba7a4d53a84766e4bf206d352a2adaa0a067c7bb13fb37ceb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|