Grokii is an AI-powered assistant bot for the devRant platform. It monitors for @mentions and responds intelligently using advanced language models via OpenRouter. The bot also includes spam detection and moderation capabilities for community maintenance.
## Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Architecture](#architecture)
- [AI Configuration](#ai-configuration)
- [Spam Detection](#spam-detection)
- [Deployment](#deployment)
- [API Reference](#api-reference)
- [License](#license)
## Overview
Grokii operates as a devRant community bot that:
1. Fetches @mentions from external JSON feed (https://static.molodetz.nl/dr.mentions.json)
2. Extracts questions and context from conversations
3. Generates intelligent responses using Grok AI (or other models via OpenRouter)
4. Posts replies back to the conversation
5. Optionally scans for and downvotes spam content
The bot is designed for the devRant developer community, understanding programming concepts, developer culture, and the platform's informal, rant-friendly atmosphere.
## Features
### AI Chat Mode (Default)
- Real-time mention monitoring with configurable polling intervals
- Context-aware responses using rant content and comment history
- Powered by x]AI Grok models via OpenRouter
- Customizable AI personality through system prompts
- Adjustable response parameters (temperature, max tokens)
- Automatic @mention reply formatting
- Dry-run mode for testing without posting
### Spam Detection Mode
- Pattern-based content analysis
- Behavioral anomaly detection
- Automatic downvoting with spam classification
- Detection categories:
- Cryptocurrency and investment scams
- Self-promotion and link spam
- Adult/NSFW content
- Phishing attempts
- Gambling promotions
- Malware and piracy links
- Excessive capitalization
- Repetitive character abuse
- Suspicious posting frequency
- Duplicate content detection
### Operational Features
- Continuous daemon mode for 24/7 operation
- Comprehensive logging with file output option
- Debug mode for troubleshooting
- Graceful shutdown handling
- Session statistics reporting
## Requirements
### System Requirements
- Swift 5.9 or later
- macOS 13+ or Linux (Ubuntu 20.04+, Debian 11+)
- Network access to devRant API and OpenRouter API
### External Services
- devRant account for the bot
- OpenRouter API key (free tier available)
## Installation
### From Source
```bash
git clone https://github.com/user/grokii.git
cd grokii
swift build -c release
sudo cp .build/release/grokii /usr/local/bin/
```
### Development Build
```bash
swift build
.build/debug/grokii --help
```
## Configuration
### Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| `OPENROUTER_API_KEY` | Yes (chat mode) | API key from openrouter.ai |
Entry point using Swift Argument Parser. Defines the `grokii` command with `chat` and `spam` subcommands. Handles authentication and bot initialization.
#### MentionBot.swift
Core mention-response logic:
- Fetches mentions from external JSON feed (https://static.molodetz.nl/dr.mentions.json)
- Filters mentions where target matches bot username
- Uses guid from JSON for deduplication
- Extracts question text by removing bot @mention
- Builds context from rant and recent comments
- Coordinates with OpenRouterClient for AI response
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.