Compare commits

4 Commits
v1.1.0 ... main

Author SHA1 Message Date
19354ba20c better error tracking 2026-03-04 22:23:49 +00:00
cfa66f592a allowing BAN_template to be populated from docker env 2026-03-04 22:05:49 +00:00
6346c1a97f changes to default ban template 2026-03-04 21:56:37 +00:00
c84fcc1faa ban template config option. 2026-03-04 21:29:58 +00:00
5 changed files with 21 additions and 8 deletions

View File

@@ -44,6 +44,7 @@ config = {
"username": "", "username": "",
"password": "", "password": "",
"sub_name": "", "sub_name": "",
"ban_template": "",
# numeric settings are stored as integers here rather than strings # numeric settings are stored as integers here rather than strings
"max_days": 180, "max_days": 180,
"max_posts": 180, "max_posts": 180,
@@ -133,9 +134,11 @@ def send_modmail(reddit: praw.Reddit, subreddit: str, subject: str, msg: str) ->
try: try:
print("Sending modmail via api/compose/") print("Sending modmail via api/compose/")
reddit.post("api/compose/", data=data) reddit.post("api/compose/", data=data)
except Exception: except Exception as e:
# fallback/report if necessary
print("Failed to send modmail with new method") print("Failed to send modmail with new method")
import traceback
print("Exception details:", repr(e))
print(traceback.format_exc())
raise raise

View File

@@ -33,13 +33,20 @@ def get_flair(flair: str) -> Flair:
def modmail_removal_notification(submission: Row, method: str) -> str: def modmail_removal_notification(submission: Row, method: str) -> str:
try:
from config import config as bot_config
ban_template = bot_config.get("ban_template", "Your custom ban message is not configured. Please contact the moderators for more information.")
except Exception:
ban_template = "Your custom ban message is not configured. Please contact the moderators for more information."
ban_text = ban_template.format(post_id=submission.post_id)
return f"""A post has been removed return f"""A post has been removed
OP: `{submission.username}` OP: `{submission.username}`
Title: {submission.title} Title: {submission.title}
Post ID: https://old.reddit.com/comments/{submission.post_id} Post ID: https://sh.reddit.com/comments/{submission.post_id}
Date created: {submission.record_created} Date created: {submission.record_created}
@@ -47,11 +54,8 @@ Date found: {submission.record_edited}
Ban Template; Ban Template;
[Deleted post](https://reddit.com/comments/{submission.post_id}). {ban_text}
"""
Deleting an answered post, without marking it solved, is against our rules.
You can read [our rules](https://reddit.com/r/MinecraftHelp/wiki/rules) to see if you're eligible to appeal this ban."""
# default template used when resetting the configuration. this mirrors # default template used when resetting the configuration. this mirrors
@@ -68,6 +72,7 @@ config = {
"username": "", "username": "",
"password": "", "password": "",
"sub_name": "", "sub_name": "",
"ban_template": "",
# numeric settings are stored as integers here rather than strings # numeric settings are stored as integers here rather than strings
"max_days": 180, "max_days": 180,
"max_posts": 180, "max_posts": 180,

View File

@@ -15,3 +15,4 @@ services:
MAX_DAYS: "${MAX_DAYS}" # strings are converted to ints when the MAX_DAYS: "${MAX_DAYS}" # strings are converted to ints when the
MAX_POSTS: "${MAX_POSTS}" # corresponding config value is an int MAX_POSTS: "${MAX_POSTS}" # corresponding config value is an int
SLEEP_MINUTES: "${SLEEP_MINUTES}" SLEEP_MINUTES: "${SLEEP_MINUTES}"
BAN_TEMPLATE: "${BAN_TEMPLATE}"

View File

@@ -15,4 +15,6 @@ SUB_NAME=example_subreddit
MAX_DAYS=180 MAX_DAYS=180
MAX_POSTS=180 MAX_POSTS=180
SLEEP_MINUTES=5 SLEEP_MINUTES=5
# Ban template option
BAN_TEMPLATE=your_ban_template_here

View File

@@ -11,6 +11,7 @@ CONFIG_KEYS = [
"max_days", "max_days",
"max_posts", "max_posts",
"sleep_minutes", "sleep_minutes",
"ban_template",
] ]
DEFAULTS = { DEFAULTS = {
@@ -23,6 +24,7 @@ DEFAULTS = {
"max_days": 180, "max_days": 180,
"max_posts": 180, "max_posts": 180,
"sleep_minutes": 5, "sleep_minutes": 5,
"ban_template": "",
} }
# Try both plain and DP_ prefix for env vars # Try both plain and DP_ prefix for env vars