An IRC bot that provides private search functionality using the Hearch API, designed for privacy and easy deployment.
Join us on MansionNET IRC to chat with us, test the bot, and play some trivia!
🌐 Server: irc.inthemansion.com
🔒 Port: 6697 (SSL)
📝 Channel: #opers, #general, #welcome, #devs (and many others)
- Privacy-focused search using Hearch's metasearch API
- Private messaging for search results to protect user privacy
- Color-coded, well-formatted search results
- Rate limiting to prevent abuse
- Automatic service management via systemd
- Easy deployment and configuration
- Python 3.8 or higher
- pip
- virtualenv
- systemd (for service management)
- Clone the repository:
git clone https://github.com/MansionNET/searchbot.git
cd searchbot
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
- Install required packages:
pip install -r requirements.txt
- Create the systemd service file:
sudo nano /etc/systemd/system/searchbot.service
- Add the following content (modify paths as needed):
[Unit]
Description=MansionNet SearchBot
After=network.target
[Service]
Type=simple
User=your_username
Group=your_username
WorkingDirectory=/path/to/searchbot
Environment=PATH=/path/to/searchbot/venv/bin
ExecStart=/path/to/searchbot/venv/bin/python searchbot.py
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
- Make the bot executable:
chmod +x searchbot.py
- Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable searchbot
sudo systemctl start searchbot
The bot supports the following commands:
!search <query>
: Performs a private web search!help
: Shows available commands and usage information
Examples:
/msg SearchBot !search python tutorial
/msg SearchBot !help
Control the bot service using standard systemd commands:
# Check status
sudo systemctl status searchbot
# View logs
sudo journalctl -u searchbot -f
# Stop the bot
sudo systemctl stop searchbot
# Restart the bot
sudo systemctl restart searchbot
Edit searchbot.py
to modify these settings:
self.server = "irc.example.com"
self.port = 6697 # SSL port
self.nickname = "SearchBot"
self.channels = ["#test_room"] # Add more channels as needed
Rate limiting can be adjusted in the RateLimiter
class:
self.rate_limiter = RateLimiter(
requests_per_minute=5,
requests_per_day=500
)
Search results are formatted with IRC color codes for better readability:
- Titles in green
- URLs in blue
- Descriptions in gray
Example output:
1. Welcome to Python.org | https://www.python.org | The mission of the Python Software Foundation...
Search results powered by https://hearch.co/ - Privacy-focused metasearch
The bot uses the Hearch API for searching, with proper rate limiting and error handling. Each request includes:
- Base64 encoded configuration
- Multiple search engine support
- Result ranking and scoring
- Custom timeout settings
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.