https://www.reddit.com/r/modguide/comments/et39hl/custom_moderation_bots/
created by kungming2 on 24/01/2020 at 01:42 UTC
24 upvotes, 4 top-level comments (showing 4)
Sometimes you want to add some features or functions to your subreddit that either AutoModerator (see our article here[1]) or or general moderation bots (see our article here[2]) can't do. Maybe you need a bot with a very particular set of skills[3]. If that's the case, maybe you need to look into getting a custom bot for your subreddit.
1: https://www.reddit.com/r/modguide/comments/db2gfy/automoderator_what_it_is_and_how_to_set_it_up/
3: https://media.giphy.com/media/UpWDPgxcHiR1e/giphy.gif
Author disclaimer: I am the writer and maintainer of u/AssistantBOT, and a mod on r/Bot, which is a subreddit for sharing moderator bots. I've also written many custom subreddit bots for my own and others' subreddits.
A custom subreddit bot is a bot that is written for and operates only on one (or a couple) subreddits. The bot does the functions the moderators of that subreddit have specifically asked it to do, and no other. Such bots are usually given a specific moderator account on the subreddit and run or hosted by the moderators of the subreddit instead of by Reddit or other users.
Here are some of the most common use cases for custom bots with examples for each:
And many more!
4: https://en.wikipedia.org/wiki/Application_programming_interface
AutoModerator is of course super useful but it has several limitations:
1. It only acts upon posts at the time of submission or editing. It cannot, say, automatically check posts several hours or days after their submission.
2. AutoModerator has no concept of a database for tasks such as points tabulation. You can try to hack something with user flairs or post flairs but it's rather inelegant and prone to error.
3. AutoModerator cannot connect to outside data sources to access or retrieve data other than the things which are already encoded into media placeholders[5].
Advantages include being able to do basically anything that you want to do with a script! Different subreddits have come up with a ton of creative ways to use bots in ways that augment and expand their community, as the above examples show. If you have a good idea and your subscribers like it, there's no reason to not have a bot.
5: https://www.reddit.com/wiki/automoderator/full-documentation#wiki_media_placeholders
Disadvantages primarily relate to the *technical* side of things.
First of all, **r/RequestABot** is the primarily place for Reddit bot requests. People can help you write a bot there, but please be sure to include as much information as possible in your request and not make a vague or low-effort request[6]. It's best if you already have a concrete idea for what you want to do with your bot. You can also look through GitHub[7] to see if there are already existing bots that fit what you need (be sure to check that they're open source though!). r/RequestABot also has a guide to running Python code someone gives you[8].
6: https://www.reddit.com/r/RequestABot/comments/e446yf/a_note_on_low_effort_posts/
7: https://github.com/topics/reddit-bot?o=desc&s=updated
Secondly, if you know how to write code, you can perhaps try writing it yourself. The most used language for writing Reddit bots is Python[9], specifically using PRAW[10] wrapper to access the Reddit API. Reddit wrappers are modules that help adapt the Reddit API in syntax and style that is appropriate for a programming language (see here for more on wrappers[11]). Check out the PRAW Quick Start guide[12] to begin familiarizing yourself with how it works.
10: https://praw.readthedocs.io/en/latest/
11: https://grantwinney.com/what-is-an-api-wrapper-and-how-do-i-write-one/
12: https://praw.readthedocs.io/en/latest/getting_started/quick_start.html
For languages other than Python, JRAW[13] is a wrapper for Java[14], Snoowrap[15] is an API wrapper for JavaScript[16], RedditSharp[17] is one for [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language%5C[18])), GRAW[19] for Go[20], and Phapper[21] is for PHP[22]. For even more languages see this list on the official archived Reddit repo[23].
13: https://github.com/mattbdean/JRAW
15: https://github.com/not-an-aardvark/snoowrap
16: https://www.javascript.com/
17: https://github.com/not-an-aardvark/snoowrap
18: https://en.wikipedia.org/wiki/C_Sharp_(programming_language%5C
19: https://github.com/turnage/graw
21: https://github.com/khicks/Phapper
23: https://github.com/reddit-archive/reddit/wiki/api-wrappers
Reddit has a host of subreddits where you can learn how to code, for example, r/learnpython for Python learners, so don't be afraid to ask the community if you have questions.
This is the tricky part. Bots are just scripts running on a user account. If a bot needs to be constantly available, the script must also be constantly running. u/Mustermind has outlined 3 options[24], and I've noted a couple more, in no particular order:
24: https://www.reddit.com/r/botwatch/comments/2261dv/bot_creators_do_any_of_you_host_your_bots_on/
1. **Heroku** (see u/PostitivePlayer1's guide here[25])
2. **Azure/EC2 Free Tier**, virtual machines (Azure guide[26], EC2 guide[27]) * These usually only give you a free year of service; after that you need to either pay or figure something else out.
3. A **Raspberry Pi**. They're cheap ($35 for the cheapest Pi 4[28]) and available on Amazon, Adafruit, and other online outlets.
4. **Your own PC/Mac**. Provided that you keep it on all the time anyway. (Note that the Pi will be a lot more energy efficient than your own computer)
5. **PythonAnywhere**. Their free tier[29] allows for a good amount of experimentation, but you may run into issues if your bot is particularly active.
6. **DigitalOcean**. Use a droplet[30] (a virtual machine).
7. **RamNode**. Link[31].
8. **ChunkHost**. Link[32].
If deploying a bot that posts or comments on areas outside of your own subreddits, please keep in mind **Bottiquette[33]**. Don't make bots that spam or are a nuisance to others.
25: https://github.com/kylelobo/Reddit-Bot/blob/master/README.md#deploying_the_bot
26: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal
27: https://aws.amazon.com/getting-started/tutorials/launch-a-virtual-machine/
28: https://www.raspberrypi.org/products/raspberry-pi-4-model-b/
29: https://www.pythonanywhere.com/pricing/
30: https://www.digitalocean.com/docs/droplets/resources/choose-plan/
33: https://www.reddit.com/wiki/bottiquette
--------------------------------------------------------------------------------
Thoughts? Comments? Let me know below!
Comment by fwump38 at 24/01/2020 at 06:48 UTC
7 upvotes, 2 direct replies
Another good subreddit to include especially if someone is trying to get started writing their own code or have questions about the Reddit API or some of the wrappers like PRAW is /r/redditdev
Also an example of a pretty useful bot on GitHub is TaskerBot[1] Disclaimer: Not mine but I based several of my first bots off of their code.
1: https://github.com/GermainZ/Taskerbot
Comment by [deleted] at 05/02/2020 at 17:34 UTC
1 upvotes, 0 direct replies
Comment by RamNode at 04/03/2020 at 19:30 UTC
1 upvotes, 0 direct replies
Thanks for the mention!
Comment by cubancutie305 at 06/09/2023 at 01:55 UTC
1 upvotes, 0 direct replies
Im ngl this hard as hell lmaooo