Examples#
Here are some examples of some bots that can be created using comis.
All of these bot examples will need to be instantiated and called with run().
See the Quickstart Guide for more details.
Automatic Comment#
Comment on posts in a subreddit automatically also pin and distinguish them.
from comis import Client, submission
class MyBot(Client):
@submission()
async def auto_comment(self, content, mod):
reply = await content.reply(
"Beep boop, this is an automated message "
"from the mods to remember to follow the rules."
)
await reply.distinguish(sticky=True)
Bad Word Filter#
Remove comments that contain bad words.
from re import compile
from comis import Client, comment
from comis.filters import flair
no_no_words = compile(r"(darn)|(heck)")
class MyBot(Client):
@flair(text=no_no_words)
@comment()
async def filter_bad_words(self, content, mod):
await mod.remove("Bad word detected")
await mod.send_removal_message(
f"Your [comment]({content.permalink}) has "
"been removed because it contains a bad word.",
type="private",
title="Comment Removed",
)
Monday Filter#
Remove all memes posted on Monday unless they are posted by a moderator or an admin.
from re import compile
from comis import Client, submission
from comis.filters import Day, author, flair, time
class MyBot(Client):
@flair(text=compile(r"\[MEME]"))
@time(days=[Day.monday])
@author(mod=False, admin=False)
@submission()
async def monday_filter(self, content, mod):
await mod.remove(mod_note="Meme filter")
await mod.send_removal_message(
"Your post has been removed automatically:\n "
"Memes are not allowed on Monday."
)