# Ragnar Bot: Automated Moderation System for Devrant.io
## Overview
Ragnar Bot is an automated system designed to interact with the **Devrant.io API** for community moderation. It detects spam, flags inappropriate content, and takes corrective actions such as downvoting and commenting. The system is scalable, customizable, and supports concurrent operations for multiple users.
## Fan-art
This is some fan art made by Buffon, a contributor of this project:
![Image generated by Buffon](buffon.jpg)
Another one:
![Image generated by Buffon](buffon2.jpg)
Third one, the legendary bot war of 2024 ended in peace.
![Image generated by Buffon](buffon3.jpg)
---
## Features
### API Integration
- **User Authentication**: Secure login with credentials.
- **Profile Retrieval**: Access user profile data.
- **Content Search**: Find posts matching specific keywords or patterns.
- **Comments Management**: Post and fetch comments on rants.
- **Voting System**: Upvote or downvote rants programmatically.
- **Fetch Rants**: Retrieve and sort recent rants for analysis.
### Spam Detection
- **Keyword Triggers**: Detect spam using predefined keywords like `crypto`, `bitcoin`, and more.
- **Regex Matching**: Identify suspicious patterns in text, such as URLs or phone numbers.
- **Heuristic Checks**: Evaluate user profiles and comments for unusual behavior.
### Automation
- **Flagging Spam**: Automatically downvote and comment on posts flagged as spam.
- **Concurrent Execution**: Operates multiple bots simultaneously using multithreading.
- **Customizable Triggers**: Adjust detection patterns to fit evolving spam trends.
### Logging & Caching
- **Logging**: Outputs activity logs to both the console and a file for debugging and monitoring.
- **Caching**: Uses a custom caching system to optimize performance and reduce redundant operations.
---
## How It Works
### Components
1. **API**:
Handles all interactions with the Devrant.io platform, including user authentication, content retrieval, and posting actions.
2. **Bot**:
Implements moderation logic:
- Identifies suspicious content.
- Posts comments warning users about flagged content.
- Maintains a history of checked rants to avoid redundant processing.
3. **CLI**:
Command-line interface to configure and execute the bot. Accepts user credentials and runs bots for multiple users simultaneously.
4. **Victoria Integration**:
Fetches user-related data from a remote service (`victoria.molodetz.nl`) for enhanced operations.
### Workflow
1. The bot authenticates using the provided username and password.
2. It retrieves and evaluates recent rants for spam indicators.
3. If spam is detected:
- Posts a predefined warning comment.
- Downvotes the rant.
4. Maintains logs and runs continuously to monitor new rants.
---
## Installation & Usage
1. **Setup**:
Clone the repository and ensure all dependencies are installed.
2. **Run the Bot**:
Execute the bot via the CLI:
```bash
python cli.py -u <username> -p <password>