Skip to content

Latest commit

 

History

History
181 lines (131 loc) · 3.69 KB

README.md

File metadata and controls

181 lines (131 loc) · 3.69 KB

SearchBot

An IRC bot that provides private search functionality using the Hearch API, designed for privacy and easy deployment.

IRC Server Details

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)

Features

  • 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

Installation

Prerequisites

  • Python 3.8 or higher
  • pip
  • virtualenv
  • systemd (for service management)

Basic Installation

  1. Clone the repository:
git clone https://github.com/MansionNET/searchbot.git
cd searchbot
  1. Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
  1. Install required packages:
pip install -r requirements.txt

Setting Up as a Service

  1. Create the systemd service file:
sudo nano /etc/systemd/system/searchbot.service
  1. 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
  1. Make the bot executable:
chmod +x searchbot.py
  1. Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable searchbot
sudo systemctl start searchbot

Usage

User Commands

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

Service Management

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

Configuration

IRC Settings

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

Rate limiting can be adjusted in the RateLimiter class:

self.rate_limiter = RateLimiter(
    requests_per_minute=5,
    requests_per_day=500
)

Technical Details

Result Formatting

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

API Integration

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

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.

Acknowledgments

  • Thanks to Hearch for providing the search API
  • Thanks to the MansionNet IRC community
  • Icons by icon8