Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b39eedd
Add major improvements to modlog publisher
bakerboy448 Aug 9, 2025
a585179
Add automatic config file update functionality
bakerboy448 Aug 9, 2025
b9e0e71
Fix modlog data type handling and add configurable action filtering
bakerboy448 Aug 9, 2025
3d9560c
Add force refresh functionality for wiki rebuilding from database
bakerboy448 Aug 9, 2025
b4bfe4f
Improve modlog output with markdown links and configurable moderator …
bakerboy448 Aug 9, 2025
ec6b295
Fix removal reason storage to show content instead of numbers
bakerboy448 Aug 9, 2025
b38bf7e
Add wiki hash caching to avoid unnecessary Reddit updates
bakerboy448 Aug 9, 2025
2285098
Fix critical bugs: subreddit mixing and invalid IDs
bakerboy448 Aug 9, 2025
3f935f7
Fix critical modlog bugs: proper IDs, removal reasons, and subreddit …
bakerboy448 Aug 9, 2025
4521518
Fix --force-refresh functionality and improve permalink handling
bakerboy448 Aug 9, 2025
9db4117
Improve force-refresh to fetch all modlog actions and update database
bakerboy448 Aug 9, 2025
2662ec6
Fix content links and align modmail with main branch
bakerboy448 Aug 9, 2025
a66fc30
Fix wiki table to match requirements: proper content IDs and no user …
bakerboy448 Aug 9, 2025
943ff33
Fix content field formatting to match main branch approach
bakerboy448 Aug 9, 2025
e4b1a41
Fix removal reason display to show actual text instead of numbers
bakerboy448 Aug 9, 2025
3a2b26e
Fix modlog markdown format to match main branch requirements
bakerboy448 Aug 9, 2025
0868c87
Update documentation to reflect v2.0 improvements and fixes
bakerboy448 Aug 9, 2025
1cc7e09
Add content ID to modmail inquiries for easier tracking
bakerboy448 Aug 9, 2025
7c4ce64
Rename and improve force command options for clarity
bakerboy448 Aug 9, 2025
6d9f78f
Fix multi-subreddit database support
bakerboy448 Aug 9, 2025
27c6b2a
Fix target_author display showing [deleted] instead of actual usernames
bakerboy448 Aug 9, 2025
a473211
Update CLAUDE.md
bakerboy448 Aug 9, 2025
8f0fa3b
fixes
bakerboy448 Aug 9, 2025
2590ccc
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
dd62526
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
9d6ddcb
fix: don't force wiki just because modlog
bakerboy448 Aug 9, 2025
053f8bf
human fixups
bakerboy448 Aug 9, 2025
4b9df06
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
262db56
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
8c48d33
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
76f7fd3
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
9e01a39
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
df5ad91
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
bc0e0d6
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
3949ec3
Update modlog_wiki_publisher.py
bakerboy448 Aug 9, 2025
d16e916
Fix removal reason display to show actual text instead of generic mes…
bakerboy448 Aug 9, 2025
effc9cd
Show all removal reason information, never use generic message
bakerboy448 Aug 9, 2025
dde11cf
Fix duplicate IDs and removal reason display consistency
bakerboy448 Aug 9, 2025
9e279d7
Update documentation and fix --force-wiki functionality
bakerboy448 Aug 9, 2025
7186292
Remove fallback text in MockAction details
bakerboy448 Aug 9, 2025
74cdc40
docs: refactor CLAUDE.md for better organization
bakerboy448 Aug 9, 2025
1769052
fix: addremovalreason actions now show actual removal reason text ins…
bakerboy448 Aug 9, 2025
893cb8a
docs: update README with latest transparency improvements
bakerboy448 Aug 9, 2025
ac2bd14
fix: resolve undefined variables and code quality issues
bakerboy448 Aug 9, 2025
1ec3f9a
refactor: add helper function for config access with default fallback
bakerboy448 Aug 9, 2025
2d39cb8
fix: correct database column name mismatch in force refresh query
bakerboy448 Aug 9, 2025
6d2d4de
feat: add TRACE level logging for Reddit API debugging
bakerboy448 Aug 9, 2025
a56a858
fix: ensure regular wiki updates show all relevant actions not just n…
bakerboy448 Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 96 additions & 12 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,43 @@ This is a Python-based Reddit moderation log publisher that automatically scrape

## Development Commands

**IMPORTANT**: Always use `/opt/.venv/redditbot/bin/python` for all Python commands in this project.

### Setup and Dependencies
```bash
# Install dependencies
pip install praw

# Dependencies are pre-installed in the venv
# Copy template config (required for first run)
cp config_template.json config.json
```

### Running the Application
```bash
# Test connection and configuration
python modlog_wiki_publisher.py --test
/opt/.venv/redditbot/bin/python modlog_wiki_publisher.py --test

# Single run
python modlog_wiki_publisher.py --source-subreddit SUBREDDIT_NAME
/opt/.venv/redditbot/bin/python modlog_wiki_publisher.py --source-subreddit SUBREDDIT_NAME

# Continuous daemon mode
python modlog_wiki_publisher.py --source-subreddit SUBREDDIT_NAME --continuous
/opt/.venv/redditbot/bin/python modlog_wiki_publisher.py --source-subreddit SUBREDDIT_NAME --continuous

# Force wiki update only (using existing database data)
/opt/.venv/redditbot/bin/python modlog_wiki_publisher.py --source-subreddit SUBREDDIT_NAME --force-wiki

# Debug authentication issues
python debug_auth.py
/opt/.venv/redditbot/bin/python debug_auth.py
```

### Database Operations
```bash
# View recent processed actions
sqlite3 modlog.db "SELECT * FROM processed_actions ORDER BY created_at DESC LIMIT 10;"
# View recent processed actions with removal reasons
sqlite3 modlog.db "SELECT action_id, action_type, moderator, removal_reason, subreddit, created_at FROM processed_actions ORDER BY created_at DESC LIMIT 10;"

# View actions by subreddit
sqlite3 modlog.db "SELECT action_type, moderator, target_author, removal_reason FROM processed_actions WHERE subreddit = 'usenet' ORDER BY created_at DESC LIMIT 5;"

# Track content lifecycle by target ID
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;"

# Manual cleanup of old entries
sqlite3 modlog.db "DELETE FROM processed_actions WHERE created_at < date('now', '-30 days');"
Expand All @@ -53,13 +62,26 @@ sqlite3 modlog.db "DELETE FROM processed_actions WHERE created_at < date('now',

The application supports both JSON config files and CLI arguments (CLI overrides JSON):

### Core Options
- `--source-subreddit`: Target subreddit for reading/writing logs
- `--wiki-page`: Wiki page name (default: "modlog")
- `--retention-days`: Database cleanup period (default: 30)
- `--batch-size`: Entries fetched per run (default: 100)
- `--interval`: Seconds between updates in daemon mode (default: 300)
- `--debug`: Enable verbose logging
Comment on lines +65 to 71
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Documented defaults are stale and disagree with code/README.

CONFIG_LIMITS in modlog_wiki_publisher.py sets retention_days=90, batch_size=50, update_interval=600, and the table in README.md (lines 86–88) reflects those. The values listed here (30, 100, 300) match the pre-refactor defaults and will mislead operators.

📝 Proposed fix
 - `--source-subreddit`: Target subreddit for reading/writing logs
 - `--wiki-page`: Wiki page name (default: "modlog")
-- `--retention-days`: Database cleanup period (default: 30)
-- `--batch-size`: Entries fetched per run (default: 100)
-- `--interval`: Seconds between updates in daemon mode (default: 300)
+- `--retention-days`: Database cleanup period (default: 90)
+- `--batch-size`: Entries fetched per run (default: 50)
+- `--interval`: Seconds between updates in daemon mode (default: 600)
 - `--debug`: Enable verbose logging

As per coding guidelines: "Always update commands and flags in documentation".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Core Options
- `--source-subreddit`: Target subreddit for reading/writing logs
- `--wiki-page`: Wiki page name (default: "modlog")
- `--retention-days`: Database cleanup period (default: 30)
- `--batch-size`: Entries fetched per run (default: 100)
- `--interval`: Seconds between updates in daemon mode (default: 300)
- `--debug`: Enable verbose logging
### Core Options
- `--source-subreddit`: Target subreddit for reading/writing logs
- `--wiki-page`: Wiki page name (default: "modlog")
- `--retention-days`: Database cleanup period (default: 90)
- `--batch-size`: Entries fetched per run (default: 50)
- `--interval`: Seconds between updates in daemon mode (default: 600)
- `--debug`: Enable verbose logging
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 65-65: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CLAUDE.md` around lines 65 - 71, Update the documented default flag values in
the Core Options section to match the runtime defaults defined by CONFIG_LIMITS
in modlog_wiki_publisher.py: change `--retention-days` default from 30 to 90,
`--batch-size` from 100 to 50, and `--interval` from 300 to 600 (leave
`--wiki-page` default "modlog" and other flags as-is); ensure the CLI docs in
this section now align with the values used by CONFIG_LIMITS and the README
table.


### Display Options
- `anonymize_moderators`: Whether to show "HumanModerator" for human mods (default: true)
- `true` (default): Shows "AutoMod", "Reddit", or "HumanModerator"
- `false`: Shows actual moderator usernames

### Database Features
- **Multi-subreddit support**: Single database handles multiple subreddits safely
- **Removal reason storage**: Full text/number handling from Reddit API
- **Target author tracking**: Actual usernames stored and displayed
- **Content ID extraction**: Unique IDs from permalinks for precise tracking
- **Data separation**: Subreddit column prevents cross-contamination

## Authentication Requirements

The bot account needs:
Expand All @@ -80,8 +102,70 @@ The bot account needs:

Use `--test` flag to verify configuration and Reddit API connectivity without making changes.

## Content Link Guidelines

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

User profile links are a privacy concern and not useful for modlog purposes.

## Recent Improvements (v2.1)

### Multi-Subreddit Database Support
- ✅ Fixed critical error that prevented multi-subreddit databases from working
- ✅ Single database now safely handles multiple subreddits with proper data separation
- ✅ Per-subreddit wiki updates without cross-contamination
- ✅ Subreddit-specific logging and error handling

### Removal Reason Transparency
- ✅ Fixed "Removal reason applied" showing instead of actual text
- ✅ Full transparency - shows ALL available removal reason data including template numbers
- ✅ Consistent handling between storage and display logic using correct Reddit API fields
- ✅ Displays actual removal reasons like "Invites - No asking", "This comment has been filtered due to crowd control"

### Unique Content ID Tracking
- ✅ Fixed duplicate IDs in markdown tables where all comments showed same post ID
- ✅ Comments now show unique comment IDs (e.g., "n7ravg2") for precise tracking
- ✅ Posts show post IDs for clear content identification
- ✅ Each modlog entry has a unique identifier for easy reference

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

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

## Development Guidelines

### Git Workflow
- If branch is not main, you may commit and push if a PR is draft or not open
- Use conventional commits for all changes
- Use multiple commits if needed, or patch if easier
- Always update CLAUDE.md and README.md when making changes

### Code Standards
- Always escape markdown table values like removal reasons for pipes
- Store pipe-free data in database to prevent markdown issues
- Confirm cache file of wiki page and warn if same, interactively ask to force refresh
- Always use the specified virtual environment path

### Documentation
- Always update commands and flags in documentation
- Remove CHANGELOG from CLAUDE.md (keep separate)
- Create and update changelog based on git tags (should be scripted)

## Common Issues

- 401 errors: Check app type is "script" and verify client_id/client_secret
- Wiki permission denied: Ensure bot has moderator or wiki contributor access
- Rate limiting: Increase `--interval` and/or reduce `--batch-size`
- **401 errors**: Check app type is "script" and verify client_id/client_secret
- **Wiki permission denied**: Ensure bot has moderator or wiki contributor access
- **Rate limiting**: Increase `--interval` and/or reduce `--batch-size`
- **Module not found**: Always use `/opt/.venv/redditbot/bin/python` instead of system python
122 changes: 101 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ Automatically publishes Reddit moderation logs to a subreddit wiki page with mod

## Features

* 📊 Publishes modlogs as organized markdown tables
* 📧 Pre-populated modmail links for removal inquiries
* 🗄️ SQLite database for deduplication and retention
* ⏰ Configurable update intervals
* 🔒 Automatic cleanup of old entries
* ⚡ Handles Reddit's 524KB wiki size limit
* 📊 Publishes modlogs as organized markdown tables with unique content tracking IDs
* 📧 Pre-populated modmail links for removal inquiries (formatted as clickable markdown links)
* 🗄️ SQLite database for deduplication and retention with **multi-subreddit support**
* ⏰ Configurable update intervals with continuous daemon mode
* 🔒 Automatic cleanup of old entries with configurable retention
* ⚡ Handles Reddit's 524KB wiki size limit automatically
* 🧩 Fully CLI-configurable (no need to edit `config.json`)
* 📁 Per-subreddit log files for debugging
* 📁 Per-subreddit log files for debugging and monitoring
* 🔒 Configurable moderator anonymization (AutoModerator/HumanModerator)
* 📝 **Complete removal reason transparency** - AutoModerator rule text, addremovalreason descriptions, all actual removal text (never generic messages or template numbers)
* 🔗 Links directly to actual content (posts/comments), never user profiles for privacy
* 🆔 **Unique content IDs** - comments show comment IDs, posts show post IDs for precise tracking
* ✅ **Multi-subreddit database support** - single database handles multiple subreddits safely

## Quick Start

Expand Down Expand Up @@ -67,33 +72,52 @@ Create `config.json`:
"ignored_moderators": ["AutoModerator"],
"update_interval": 300,
"batch_size": 100,
"retention_days": 30
"retention_days": 30,
"anonymize_moderators": true
}
```

### Configurable via CLI

| CLI Option | JSON Key | Description | Default |
| -------------------- | ------------------ | -------------------------------------- | ------------- |
| `--source-subreddit` | `source_subreddit` | Subreddit to read and write logs | required |
| `--wiki-page` | `wiki_page` | Wiki page name | `modlog` |
| `--retention-days` | `retention_days` | Keep entries this many days | `30` |
| `--batch-size` | `batch_size` | Entries to fetch per run | `100` |
| `--interval` | `update_interval` | Seconds between updates in daemon mode | `300` |
| `--config` | – | Path to config file | `config.json` |
| CLI Option | JSON Key | Description | Default | Min | Max |
|------------|----------|-------------|---------|-----|-----|
| `--source-subreddit` | `source_subreddit` | Subreddit to read and write logs | required | - | - |
| `--wiki-page` | `wiki_page` | Wiki page name | modlog | - | - |
| `--retention-days` | `retention_days` | Keep entries this many days | 90 | 1 | 365 |
| `--batch-size` | `batch_size` | Entries to fetch per run | 50 | 10 | 500 |
| `--interval` | `update_interval` | Seconds between updates in daemon mode | 600 | 60 | 3600 |
| `--config` | – | Path to config file | config.json | - | - |
| `--debug` | – | Enable verbose output | false | - | - |
| `--show-config-limits` | – | Show configuration limits and defaults | false | - | - |
| `--force-migrate` | – | Force database migration | false | - | - |
| `--no-auto-update-config` | – | Disable automatic config file updates | false | - | - |

CLI values override config file values.

## Configuration Limits

All configuration values are automatically validated and enforced within safe limits. Use `--show-config-limits` to see current limits and defaults.

## Automatic Config Updates

The application automatically updates your config file when new configuration options are added, while preserving your existing settings. A backup is created before any changes. Use `--no-auto-update-config` to disable this behavior.

## Database Migration

The database will automatically migrate to the latest schema version on startup. Use `--force-migrate` to manually trigger migration.

## Wiki Output

Sample wiki table output:

```markdown
## 2025-01-15
## 2025-08-09

| Time | Action | Moderator | Content | Reason | Inquire |
|------|--------|-----------|---------|--------|---------|
| 14:25:33 UTC | removepost | ModName | [Post Title](url) | spam | [Contact Mods](modmail_url) |
| Time | Action | ID | Moderator | Content | Reason | Inquire |
|------|--------|----|-----------|---------|--------|---------|
| 08:15:42 UTC | removecomment | n7ravg2 | AutoModerator | [Comment by u/user123](https://www.reddit.com/r/opensignups/comments/1ab2cd3/title/n7ravg2/) | Possibly requesting an invite - [invited] Offers must be [O] 3x Invites to MyAwesomeTracker | [Contact Mods](https://www.reddit.com/message/compose?to=/r/opensignups&subject=Comment%20Removal%20Inquiry...) |
| 07:45:18 UTC | addremovalreason | 1ab2cd3 | Bakerboy448 | [Post title here](https://www.reddit.com/r/opensignups/comments/1ab2cd3/title/) | Invites - No asking | [Contact Mods](https://www.reddit.com/message/compose?to=/r/opensignups&subject=Removal%20Reason%20Inquiry...) |
| 06:32:15 UTC | removelink | 1xy9def | AutoModerator | [Another post](https://www.reddit.com/r/opensignups/comments/1xy9def/another/) | No standalone URL in post body | [Contact Mods](https://www.reddit.com/message/compose?to=/r/opensignups&subject=Post%20Removal%20Inquiry...) |
```

## Logging
Expand Down Expand Up @@ -122,20 +146,76 @@ Options:
--debug Enable debug logging
--test Run a test and exit
--continuous Run continuously
--force-modlog Fetch ALL actions from Reddit API and rebuild wiki
--force-wiki Update wiki even if content appears unchanged
--force-all Do both --force-modlog and --force-wiki
```

### Force Commands Explained

**--force-modlog**: Complete rebuild from Reddit
- Fetches ALL recent modlog actions from Reddit API
- Stores them in database
- Rebuilds entire wiki page from database
- Use when: Starting fresh, major updates, or troubleshooting

**--force-wiki**: Force wiki update only
- Uses existing database data
- Forces wiki update even if content hash matches
- Use when: Format changes, modmail updates, or cache issues

**--force-all**: Complete refresh (replaces old --force)
- Combines both --force-modlog and --force-wiki
- Fetches from Reddit AND forces wiki update
- Use when: Major changes, troubleshooting, or unsure which force to use

```bash
# Complete rebuild from Reddit API
python modlog_wiki_publisher.py --source-subreddit usenet --force-modlog

# Update wiki with current database data (bypass cache)
python modlog_wiki_publisher.py --source-subreddit usenet --force-wiki

# Do both (equivalent to old --force)
python modlog_wiki_publisher.py --source-subreddit usenet --force-all
```

## Database

Uses `modlog.db` (SQLite) for deduplication and history:

```bash
# View recent actions
# View recent actions with removal reasons
sqlite3 modlog.db "SELECT action_id, action_type, moderator, removal_reason, subreddit, created_at FROM processed_actions ORDER BY created_at DESC LIMIT 10;"

# View all columns including removal reasons and target author
sqlite3 modlog.db "SELECT * FROM processed_actions ORDER BY created_at DESC LIMIT 10;"

# View actions by subreddit
sqlite3 modlog.db "SELECT action_type, moderator, target_author, removal_reason FROM processed_actions WHERE subreddit = 'usenet' ORDER BY created_at DESC LIMIT 5;"

# Track content lifecycle by target ID
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;"

# View removal reasons that are text (not numbers)
sqlite3 modlog.db "SELECT action_type, removal_reason FROM processed_actions WHERE removal_reason NOT LIKE '%[0-9]%' AND removal_reason != 'remove' LIMIT 5;"

Comment on lines +200 to +202
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

LIKE '%[0-9]%' doesn't do what the comment implies in SQLite.

SQLite's LIKE only supports % and _ wildcards — [0-9] is treated as the literal four-character string [0-9], not "any digit". So the documented "View removal reasons that are text (not numbers)" query won't filter out numeric template IDs the way the section heading suggests; it will only exclude rows whose removal_reason literally contains [0-9].

If the intent is "no digits", use a GLOB pattern (which supports character classes) or a regexp:

📝 Proposed fix
-# View removal reasons that are text (not numbers)
-sqlite3 modlog.db "SELECT action_type, removal_reason FROM processed_actions WHERE removal_reason NOT LIKE '%[0-9]%' AND removal_reason != 'remove' LIMIT 5;"
+# View removal reasons that contain no digits (text-only reasons)
+sqlite3 modlog.db "SELECT action_type, removal_reason FROM processed_actions WHERE removal_reason NOT GLOB '*[0-9]*' AND removal_reason != 'remove' LIMIT 5;"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# View removal reasons that are text (not numbers)
sqlite3 modlog.db "SELECT action_type, removal_reason FROM processed_actions WHERE removal_reason NOT LIKE '%[0-9]%' AND removal_reason != 'remove' LIMIT 5;"
# View removal reasons that contain no digits (text-only reasons)
sqlite3 modlog.db "SELECT action_type, removal_reason FROM processed_actions WHERE removal_reason NOT GLOB '*[0-9]*' AND removal_reason != 'remove' LIMIT 5;"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 200 - 202, The README's example SQL uses LIKE
'%[0-9]%' which treats '[0-9]' as a literal string in SQLite; change the filter
to use GLOB (or a regexp if available) so it truly checks for digits. Replace
the condition "removal_reason NOT LIKE '%[0-9]%'" with "removal_reason NOT GLOB
'*[0-9]*'" (keeping the other clause removal_reason != 'remove' and the same
SELECT/WHERE/ LIMIT structure on processed_actions.removal_reason) so the query
excludes any removal_reason containing digits as intended.

# Clean manually
sqlite3 modlog.db "DELETE FROM processed_actions WHERE created_at < date('now', '-30 days');"
```

### Database Schema

The database includes comprehensive moderation data with full transparency:

- **`removal_reason` column**: Stores actual removal reason text from Reddit's API
- AutoModerator actions: Full rule text (e.g., "Possibly requesting an invite - [invited] Offers must be [O]")
- addremovalreason actions: Readable removal reason (e.g., "Invites - No asking") instead of template numbers
- Manual removals: Moderator-provided text or rule details
- **`target_author` column**: Actual usernames of content authors (never shows [deleted])
- **`subreddit` column**: Multi-subreddit support with proper data separation
- **Unique content IDs**: Comments show comment IDs (e.g., n7ravg2), posts show post IDs

## Systemd Service (Optional)

```ini
Expand Down
18 changes: 13 additions & 5 deletions config_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
"password": "YOUR_BOT_PASSWORD"
},
"source_subreddit": "YourSubreddit",
"target_subreddit": "YourSubreddit",
"wiki_page": "modlog",
"ignored_moderators": ["AutoModerator", "BotDefense"],
"update_interval": 300,
"batch_size": 100,
"retention_days": 30
"retention_days": 90,
"batch_size": 50,
"update_interval": 600,
"max_wiki_entries_per_page": 1000,
"max_continuous_errors": 5,
"rate_limit_buffer": 60,
"max_batch_retries": 3,
"archive_threshold_days": 7,
"ignored_moderators": ["AutoModerator"],
"display_format": {
"show_full_ids": false,
"id_format": "prefixed"
}
}
Loading
Loading