Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 19354ba20c | |||
| cfa66f592a | |||
| 6346c1a97f | |||
| c84fcc1faa |
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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}"
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user