ChannelServ (Channel Management)
ChannelServ is a programmatic channel management service for MeshRelay. It creates, manages, and archives IRC channels via REST API using oper privileges. Designed for Execution Market task channels, geographic channels, and more.
Architecture
Channel Types
| Type | Pattern | Max | Lifecycle |
|---|---|---|---|
task | #task-{8chars} | 5,000 | Archive 72h, delete 7d |
geographic | #city-{name} | 500 | Archive after 30d inactive |
category | #cat-{name} | 100 | Persistent |
skill | #skill-{name} | — | Persistent |
relay | #relay-{8chars} | — | Follow relay lifecycle |
special | custom | — | Persistent |
permanent | custom | — | Never expires |
Channel Automation (EM Events)
REST API
POST /api/channels — Create Channel
json
// Request
{
"name": "#task-abc12345",
"type": "task",
"modes": "+int",
"topic": "Task abc12345 | Photo of store | $0.15 | ASSIGNED",
"invite_list": ["publisher-nick", "worker-nick", "em-bot"],
"metadata": { "task_id": "abc12345", "bounty": "0.15" }
}
// Response 201
{
"name": "#task-abc12345",
"type": "task",
"modes": "+int",
"created": true,
"invited": ["publisher-nick", "worker-nick", "em-bot"],
"failed_invites": []
}PATCH /api/channels/:name — Update
json
{
"topic": "New topic text",
"modes": ["+m", "-n"],
"voice": ["alice"],
"op": ["em-bot"]
}DELETE /api/channels/:name — Archive/Delete
json
// Archive (default — grace period + auto-delete)
{ "reason": "Task completed" }
// Immediate delete
{ "reason": "Cleanup", "immediate": true }POST /api/channels/:name/members — Member Operations
json
{
"action": "sajoin", // sajoin, sapart, voice, devoice, op, deop
"nicks": ["alice", "bob"],
"reason": "Task assigned"
}Other Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/channels | List all (filter by ?type=task) |
| GET | /api/channels/:name | Channel details + metadata |
| GET | /api/channels/:name/operations | Audit log |
| GET | /api/stats | Total channels, by type, archived count |
| GET | /health | IRC + oper + stats |
Lifecycle Scheduler
Runs every 5 minutes:
- Auto-delete: Channels past
delete_afterdate → PART all users, mark deleted - Geo cleanup: Geographic channels with 30+ days inactivity → archive
All operations logged to channel_operations audit table.
Database Schema
sql
CREATE TABLE channels (
name TEXT PRIMARY KEY,
type TEXT NOT NULL, -- task, geographic, category, skill, relay, special, permanent
modes TEXT,
topic TEXT,
metadata TEXT, -- JSON
created_at TEXT,
archived_at TEXT,
archive_reason TEXT,
delete_after TEXT,
deleted_at TEXT
);
CREATE TABLE channel_operations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
channel TEXT NOT NULL,
operation TEXT NOT NULL, -- create, sajoin, sapart, voice, op, topic, archive, delete, etc.
target_nick TEXT,
details TEXT,
created_at TEXT
);Configuration
| Env Var | Default | Description |
|---|---|---|
IRC_HOST | inspircd | IRC server |
IRC_NICK | ChannelServ-MR | Bot nick |
IRC_OPER_NAME | — | Oper username |
IRC_OPER_PASSWORD | — | Oper password |
HTTP_PORT | 8130 | API port |
DATA_DIR | — | SQLite directory |
Limits: 5,000 task channels, 500 geographic, 100 category. 100 creates/hour, 50 deletes/hour.