- Python 93.4%
- Shell 5.4%
- Batchfile 1.1%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Security: - _is_owner: hostmask-only lookup (no username/nick match) — closes nickjack privilege escalation - _sanitize_input: strip \n/\r and all non-printables — closes IRC protocol injection via !join/!part/!botnick - mac.py: remove hardcoded API key; read from config[mac_api_key] - config.py + install.py: never persist db_password to config.json Fixed: - massmeet: per-user SAVEPOINT/RELEASE/ROLLBACK TO — one UNIQUE violation no longer poisons the batch; merges no longer discarded - events: first-match-wins command dispatch (break) — fixes !avail double-answer - events: hyphen in command regex — !bd-set now parses - events: _split_message caps combined output at 500 chars — prevents 512-byte IRC line disconnect - deluser: cascade-delete infoitems/quotes/karma_who/autoop rows - debug: per-event logging gated behind !debug toggle - startup.sh: remove dead phreakbot_pydle.py branch - modules.py: remove duplicate avail registration (help.py is canonical) Removed: - modules/roa.py (deprecated; !roa in irrexplorer.py) - contrib/ (dead pre-pydle code) - six *_gaps.py skeleton test files (2315 lines of pass-bodies) - bot.re, bot_trigger_re, user_permissions cache - pycurl dependency (unused) 313 tests passing. |
||
| docs | ||
| modules | ||
| phreakbot_core | ||
| scripts | ||
| tests | ||
| .coveragerc | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| CHANGELOG.md | ||
| config.json.pydle.example | ||
| create-autovoice-table.sql | ||
| dbschema.psql | ||
| docker-compose.yml | ||
| Dockerfile | ||
| install.py | ||
| LICENSE | ||
| phreakbot.py | ||
| pytest.ini | ||
| README.md | ||
| requirements.txt | ||
| VERSION | ||
PhreakBot (v0.1.42)
PhreakBot is a modular IRC bot written in Python.
Features
- Modular design with easy-to-add modules
- Permission system with owner, admin, and user levels
- Quote database with search functionality
- URL title and description fetching
- Channel management (join, part, topic)
- User registration and management
- Auto-op functionality
- CTCP version support
- Robust error handling and logging
- Frys-IX peering LAN member information with port speed, IP, and max prefix details
- MAC address vendor lookup for both full and partial MAC addresses
- Mass user registration and hostmask merging
- ROA validation and routing information
- Karma system with ++ and -- support
- And more!
Installation
Docker / Podman (Recommended)
PhreakBot supports both Docker and Podman.
-
Copy
.env.exampleto.envand update the values:cp .env.example .env -
Start the bot:
Using Docker:
docker-compose up -dUsing Podman:
podman-compose up -d
For detailed Podman instructions and features, see docs/PODMAN.md.
Manual Installation
- Clone the repository
- Install the required dependencies:
pip install -r requirements.txt - Set up a PostgreSQL database
- Run the SQL in
dbschema.psqlto create the necessary tables - Configure the bot by editing
config/config.json - Run the bot:
python phreakbot.py
PhreakBot uses the pydle IRC library, which offers:
- Better handling of IRC events
- Improved connection stability
- Enhanced support for custom commands like
!item = valueand!item? - More detailed logging
- Asynchronous operation for better performance
Scripts
All utility scripts are located in the scripts/ directory. See scripts/README.md for detailed information about each script.
Configuration
Docker / Podman
Configure via environment variables in .env (see .env.example for defaults):
# PostgreSQL credentials — POSTGRES_PASSWORD is required, no default
POSTGRES_USER=phreakbot
POSTGRES_PASSWORD=changeme
POSTGRES_DB=phreakbot
# IRC configuration — TLS on port 6697 is the default
IRC_SERVER=irc.libera.chat
IRC_PORT=6697
IRC_NICKNAME=PhreakBot
IRC_CHANNEL=#phreakbot
Manual Installation
Edit config/config.json to configure the bot:
{
"server": "irc.example.com",
"port": 6697,
"use_tls": true,
"tls_verify": true,
"nickname": "PhreakBot",
"realname": "PhreakBot",
"channels": ["#channel1", "#channel2"],
"command_trigger": "!"
}
Setting Up Ownership
When the bot first starts, use the !owner claim command to claim ownership of the bot. This will grant you admin privileges and allow you to manage the bot.
Module Development
Modules are stored in the modules directory. Each module should have a config function that returns a dictionary with the following keys:
events: List of IRC events to listen forcommands: List of commands the module providespermissions: List of permissions required to use the modulehelp: Help text for the module
For detailed information on how to create your own modules, see the Module Development Guide.
Security
- IRC connections default to TLS on port 6697 (
use_tls: true). Plaintext port 6667 is intentionally not the default. POSTGRES_PASSWORDmust be set explicitly — the bot refuses to start if it is empty.- URL fetching (
!url, auto-title,!@) is protected against SSRF: all redirect hops are re-checked against a blocked-network list (RFC 1918, loopback, link-local, cloud metadata endpoints). - The
!ipcommand only reports public IP addresses; private/reserved addresses are blocked from output. - The permission system enforces an allowlist of valid permission names; unknown values are rejected at write time.
- Exception details are never sent to IRC channels; full errors are logged server-side only.
See CHANGELOG.md for the full history of security fixes.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.