Skip to content

Commit 1b861a6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 90b96ab commit 1b861a6

16 files changed

Lines changed: 1166 additions & 703 deletions

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ systemd/
5353
# Docker files (not needed in build context)
5454
docker-compose.yml
5555
docker-compose.*.yml
56-
Dockerfile.*
56+
Dockerfile.*

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ jobs:
118118
uses: github/codeql-action/upload-sarif@v3
119119
if: always()
120120
with:
121-
sarif_file: 'trivy-results.sarif'
121+
sarif_file: 'trivy-results.sarif'

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ repos:
5454
entry: python -c "import json; config = json.load(open('config.json')) if __import__('os').path.exists('config.json') else {}; exit(1) if not config.get('anonymize_moderators', True) else exit(0)"
5555
language: system
5656
files: config\.json$
57-
pass_filenames: false
57+
pass_filenames: false

CLAUDE.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ sqlite3 modlog.db "SELECT action_id, action_type, moderator, removal_reason, sub
5151
# View actions by subreddit
5252
sqlite3 modlog.db "SELECT action_type, moderator, target_author, removal_reason FROM processed_actions WHERE subreddit = 'usenet' ORDER BY created_at DESC LIMIT 5;"
5353

54-
# Track content lifecycle by target ID
54+
# Track content lifecycle by target ID
5555
sqlite3 modlog.db "SELECT target_id, action_type, moderator, removal_reason, datetime(created_at, 'unixepoch') FROM processed_actions WHERE target_id LIKE '%1mkz4jm%' ORDER BY created_at;"
5656

5757
# Manual cleanup of old entries
@@ -62,7 +62,7 @@ sqlite3 modlog.db "DELETE FROM processed_actions WHERE created_at < date('now',
6262

6363
The application supports multiple configuration methods with the following priority (highest to lowest):
6464
1. **Command line arguments** (highest priority)
65-
2. **Environment variables** (override config file)
65+
2. **Environment variables** (override config file)
6666
3. **JSON config file** (base configuration)
6767

6868
### Environment Variables
@@ -71,7 +71,7 @@ All configuration options can be set via environment variables:
7171

7272
#### Reddit Credentials
7373
- `REDDIT_CLIENT_ID`: Reddit app client ID
74-
- `REDDIT_CLIENT_SECRET`: Reddit app client secret
74+
- `REDDIT_CLIENT_SECRET`: Reddit app client secret
7575
- `REDDIT_USERNAME`: Reddit bot username
7676
- `REDDIT_PASSWORD`: Reddit bot password
7777

@@ -132,7 +132,7 @@ python modlog_wiki_publisher.py --debug --batch-size 25 # CLI takes priority
132132

133133
### Display Options
134134
- `anonymize_moderators`: **REQUIRED** to be `true` for security (default: true)
135-
- `true` (ENFORCED): Shows "AutoModerator", "Reddit", or "HumanModerator"
135+
- `true` (ENFORCED): Shows "AutoModerator", "Reddit", or "HumanModerator"
136136
- `false`: **BLOCKED** - Would expose moderator identities publicly
137137

138138
**SECURITY NOTE**: Setting `anonymize_moderators=false` is permanently disabled to protect moderator privacy. The application will refuse to start if this is attempted.
@@ -143,7 +143,7 @@ The application uses configurable action type variables for flexibility:
143143

144144
#### Default Configuration
145145
- **REMOVAL_ACTIONS**: `removelink`, `removecomment`, `spamlink`, `spamcomment`
146-
- **APPROVAL_ACTIONS**: `approvelink`, `approvecomment`
146+
- **APPROVAL_ACTIONS**: `approvelink`, `approvecomment`
147147
- **REASON_ACTIONS**: `addremovalreason`
148148
- **DEFAULT_WIKI_ACTIONS**: All above combined
149149

@@ -184,7 +184,7 @@ Use `--test` flag to verify configuration and Reddit API connectivity without ma
184184
## Content Link Guidelines
185185

186186
**CRITICAL**: Content links in the modlog should NEVER point to user profiles (`/u/username`). Links should only point to:
187-
- Actual removed posts (`/comments/postid/`)
187+
- Actual removed posts (`/comments/postid/`)
188188
- Actual removed comments (`/comments/postid/_/commentid/`)
189189
- No link at all if no actual content is available
190190

@@ -231,14 +231,14 @@ User profile links are a privacy concern and not useful for modlog purposes.
231231

232232
### Content Linking and Display
233233
- ✅ Content links point to actual Reddit posts/comments, never user profiles for privacy
234-
- ✅ Fixed target authors showing as [deleted] - now displays actual usernames
234+
- ✅ Fixed target authors showing as [deleted] - now displays actual usernames
235235
- ✅ Proper content titles extracted from Reddit API data
236236
- ✅ AutoModerator displays as "AutoModerator" (not anonymized)
237237
- ✅ Configurable anonymization for human moderators
238238

239239
### Data Integrity
240240
- ✅ Pipe character escaping for markdown table compatibility
241-
- ✅ Robust error handling for mixed subreddit scenarios
241+
- ✅ Robust error handling for mixed subreddit scenarios
242242
- ✅ Database schema at version 5 with all required columns
243243
- ✅ Consistent Reddit API field usage (action.details vs action.description)
244244

@@ -266,4 +266,4 @@ User profile links are a privacy concern and not useful for modlog purposes.
266266
- **401 errors**: Check app type is "script" and verify client_id/client_secret
267267
- **Wiki permission denied**: Ensure bot has moderator or wiki contributor access
268268
- **Rate limiting**: Increase `--interval` and/or reduce `--batch-size`
269-
- **Module not found**: Always use `/opt/.venv/redditbot/bin/python` instead of system python
269+
- **Module not found**: Always use `/opt/.venv/redditbot/bin/python` instead of system python

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ HEALTHCHECK --interval=5m --timeout=10s --start-period=30s --retries=3 \
142142
CMD python -c "import os, sys; sys.exit(0 if os.path.exists(os.getenv('DATABASE_PATH', '/config/data/modlog.db')) else 1)"
143143

144144
# Use s6-overlay as entrypoint
145-
ENTRYPOINT ["/init"]
145+
ENTRYPOINT ["/init"]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Automatically publishes Reddit moderation logs to a subreddit wiki page with mod
99
* 🗄️ SQLite database for deduplication and retention with **multi-subreddit support**
1010
* ⏰ Configurable update intervals with continuous daemon mode
1111
* 🔒 Automatic cleanup of old entries with configurable retention
12-
* ⚡ Handles Reddit's 524KB wiki size limit automatically
12+
* ⚡ Handles Reddit's 524KB wiki size limit automatically
1313
* 🧩 Fully CLI-configurable (no need to edit `config.json`)
1414
* 📁 Per-subreddit log files for debugging and monitoring
1515
* 🔒 Configurable moderator anonymization (AutoModerator/HumanModerator)
@@ -162,7 +162,7 @@ Options:
162162
### Force Commands Explained
163163
164164
**--force-modlog**: Complete rebuild from Reddit
165-
- Fetches ALL recent modlog actions from Reddit API
165+
- Fetches ALL recent modlog actions from Reddit API
166166
- Stores them in database
167167
- Rebuilds entire wiki page from database
168168
- Use when: Starting fresh, major updates, or troubleshooting
@@ -181,7 +181,7 @@ Options:
181181
# Complete rebuild from Reddit API
182182
python modlog_wiki_publisher.py --source-subreddit usenet --force-modlog
183183
184-
# Update wiki with current database data (bypass cache)
184+
# Update wiki with current database data (bypass cache)
185185
python modlog_wiki_publisher.py --source-subreddit usenet --force-wiki
186186
187187
# Do both (equivalent to old --force)

config_template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
"show_full_ids": false,
2121
"id_format": "prefixed"
2222
}
23-
}
23+
}

debug_auth.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env python3
2-
import json
32
import base64
3+
import json
4+
45
import requests
56

67
# Load config
7-
with open('config.json') as f:
8+
with open("config.json") as f:
89
config = json.load(f)
910

10-
reddit = config['reddit']
11+
reddit = config["reddit"]
1112

1213
print("=" * 50)
1314
print("Reddit Auth Debug")
@@ -19,28 +20,28 @@
1920
print(f"Client Secret first 4: {reddit['client_secret'][:4]}...")
2021

2122
# Check for common issues
22-
if len(reddit['client_id']) > 20:
23+
if len(reddit["client_id"]) > 20:
2324
print("⚠️ Client ID seems too long - might be using secret as ID?")
24-
if len(reddit['client_secret']) < 20:
25+
if len(reddit["client_secret"]) < 20:
2526
print("⚠️ Client Secret seems too short - might be using ID as secret?")
2627

2728
# Test manual auth
2829
print("\nTesting manual authentication...")
29-
auth = base64.b64encode(f"{reddit['client_id']}:{reddit['client_secret']}".encode()).decode()
30+
auth = base64.b64encode(
31+
f"{reddit['client_id']}:{reddit['client_secret']}".encode()
32+
).decode()
3033
headers = {
3134
"Authorization": f"Basic {auth}",
32-
"User-Agent": f"ModlogWikiPublisher/1.0 by /u/{reddit['username']}"
35+
"User-Agent": f"ModlogWikiPublisher/1.0 by /u/{reddit['username']}",
3336
}
3437
data = {
3538
"grant_type": "password",
36-
"username": reddit['username'],
37-
"password": reddit['password']
39+
"username": reddit["username"],
40+
"password": reddit["password"],
3841
}
3942

4043
response = requests.post(
41-
"https://www.reddit.com/api/v1/access_token",
42-
headers=headers,
43-
data=data
44+
"https://www.reddit.com/api/v1/access_token", headers=headers, data=data
4445
)
4546

4647
print(f"\nResponse Status: {response.status_code}")
@@ -53,4 +54,4 @@
5354
print("2. Client ID = the string under 'personal use script' (shorter)")
5455
print("3. Client Secret = the 'secret' field (longer)")
5556
print("4. Make sure the app type is 'script' not 'web app'")
56-
print("5. Username should be just 'Bakerboy448' not 'u/Bakerboy448'")
57+
print("5. Username should be just 'Bakerboy448' not 'u/Bakerboy448'")

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ services:
6161
# - SOURCE_SUBREDDIT=${SOURCE_SUBREDDIT_2}
6262
# volumes:
6363
# - ./data2:/config/data
64-
# - ./logs2:/config/logs
64+
# - ./logs2:/config/logs

0 commit comments

Comments
 (0)