Skip to content

Commit 28a6f5c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 63e8a4f commit 28a6f5c

14 files changed

Lines changed: 1104 additions & 687 deletions

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ docker-compose.yml
8787

8888
# Reddit specific
8989
processed_actions.json
90-
modlog_backup_*.json
90+
modlog_backup_*.json

.github/copilot-instructions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is a Python-based Reddit moderation log publisher that scrapes mod actions
55

66
## Code Style & Standards
77
- **No comments on self-documenting code** - avoid obvious comments
8-
- **Use conventional commits** for all changes
8+
- **Use conventional commits** for all changes
99
- **Environment variables** for all configuration (Docker-ready)
1010
- **Security first**: Never expose moderator identities, always anonymize
1111
- **Error handling**: Graceful degradation, comprehensive logging
@@ -43,7 +43,7 @@ This is a Python-based Reddit moderation log publisher that scrapes mod actions
4343

4444
## Testing & Quality
4545
- **Pre-commit hooks**: Black, flake8, isort, mypy, security scanning
46-
- **Validation**: Strict input validation with clear error messages
46+
- **Validation**: Strict input validation with clear error messages
4747
- **Environment testing**: `--test` flag for configuration validation
4848
- **CI/CD**: Multi-platform builds with manual approval for main branch
4949

@@ -55,14 +55,14 @@ This is a Python-based Reddit moderation log publisher that scrapes mod actions
5555

5656
## Forbidden Patterns
5757
- ❌ Hardcoded credentials or configuration
58-
- ❌ User profile links in public wikis
58+
- ❌ User profile links in public wikis
5959
- ❌ Unescaped markdown content in tables
6060
- ❌ Missing error handling for Reddit API calls
6161
- ❌ Exposing real moderator names in production
6262

6363
## Preferred Libraries
6464
- **PRAW**: Reddit API wrapper (already in use)
65-
- **SQLite3**: Database (already in use)
65+
- **SQLite3**: Database (already in use)
6666
- **Apprise**: Future notification support
6767
- **Standard library**: Prefer built-in modules when possible
6868

@@ -72,4 +72,4 @@ This is a Python-based Reddit moderation log publisher that scrapes mod actions
7272
- **Manual approval**: Never auto-merge to main branch
7373
- **Conventional commits**: Use standard commit message format
7474

75-
When suggesting code improvements, prioritize security, reliability, and maintainability over clever optimizations.
75+
When suggesting code improvements, prioritize security, reliability, and maintainability over clever optimizations.

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ jobs:
8383
username: ${{ secrets.DOCKERHUB_USERNAME }}
8484
password: ${{ secrets.DOCKERHUB_TOKEN }}
8585
repository: ${{ env.IMAGE_NAME }}
86-
readme-filepath: ./README.md
86+
readme-filepath: ./README.md

.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

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

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

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

142142
#### Default Configuration
143143
- **REMOVAL_ACTIONS**: `removelink`, `removecomment`, `spamlink`, `spamcomment`
144-
- **APPROVAL_ACTIONS**: `approvelink`, `approvecomment`
144+
- **APPROVAL_ACTIONS**: `approvelink`, `approvecomment`
145145
- **REASON_ACTIONS**: `addremovalreason`
146146
- **DEFAULT_WIKI_ACTIONS**: All above combined
147147

@@ -182,7 +182,7 @@ Use `--test` flag to verify configuration and Reddit API connectivity without ma
182182
## Content Link Guidelines
183183

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

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

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

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

@@ -335,4 +335,4 @@ pre-commit run --all-files
335335
- **401 errors**: Check app type is "script" and verify client_id/client_secret
336336
- **Wiki permission denied**: Ensure bot has moderator or wiki contributor access
337337
- **Rate limiting**: Increase `--interval` and/or reduce `--batch-size`
338-
- **Module not found**: Always use `/opt/.venv/redditbot/bin/python` instead of system python
338+
- **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
@@ -53,4 +53,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
5353
CMD python -c "import sqlite3; conn = sqlite3.connect('${DB_PATH}'); conn.close()" || exit 1
5454

5555
# Default command - can be overridden
56-
CMD ["python", "modlog_wiki_publisher.py", "--continuous"]
56+
CMD ["python", "modlog_wiki_publisher.py", "--continuous"]

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)
@@ -154,7 +154,7 @@ Options:
154154
### Force Commands Explained
155155
156156
**--force-modlog**: Complete rebuild from Reddit
157-
- Fetches ALL recent modlog actions from Reddit API
157+
- Fetches ALL recent modlog actions from Reddit API
158158
- Stores them in database
159159
- Rebuilds entire wiki page from database
160160
- Use when: Starting fresh, major updates, or troubleshooting
@@ -173,7 +173,7 @@ Options:
173173
# Complete rebuild from Reddit API
174174
python modlog_wiki_publisher.py --source-subreddit usenet --force-modlog
175175
176-
# Update wiki with current database data (bypass cache)
176+
# Update wiki with current database data (bypass cache)
177177
python modlog_wiki_publisher.py --source-subreddit usenet --force-wiki
178178
179179
# Do both (equivalent to old --force)

apprise-notification-feature-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ None - this is an optional feature that defaults to disabled.
142142
**Priority**: Medium
143143
**Complexity**: Medium
144144
**Estimated effort**: 1-2 days development + testing
145-
**Dependencies**: None (Apprise is optional)
145+
**Dependencies**: None (Apprise is optional)

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'")

0 commit comments

Comments
 (0)