# SnekBot: Your Instant Chat Companion ## Create Your Own Bot in Minutes ### Overview SnekBot is designed for rapid deployment and customization, providing a fully asynchronous and production-ready chat bot solution. It is built to handle network issues effectively, ensuring a reliable user experience. ### Prerequisites - Python 3.8 or higher - Basic understanding of Python programming ### Installation Instructions #### 1. Prepare Your Environment ```bash # For Ubuntu/Debian users: sudo apt install python3 python3-venv python3-pip -y # Create a virtual environment for your bot python3 -m venv venv source venv/bin/activate ``` #### 2. Install SnekBot ```bash pip install git+https://molodetz.nl/retoor/snekbot.git ``` ### Bot Development To create your bot, use the following template: ```python import asyncio from snekbot.bot import Bot class CustomSnekBot(Bot): async def on_join(self, channel_uid): await self.send_message( channel_uid, "Hello! I am here to assist you." ) async def on_message(self, sender_username, sender_nick, channel_uid, message): message = message.lower() if "hello" in message: await self.send_message(channel_uid, f"Greetings, {sender_nick}!") elif "bye" in message: await self.send_message(channel_uid, f"Goodbye, {sender_nick}!") # Initialize your bot bot = CustomSnekBot( url="wss://your-snek-instance.com/rpc.ws", username="your_bot_username", password="your_secure_password" ) asyncio.run(bot.run()) ``` ### Running Your Bot ```bash python your_bot_script.py ``` ### Event Handlers You can override the following event handlers: - `on_join`: Triggered when the bot joins a channel - `on_leave`: Triggered when the bot leaves a channel - `on_ping`: Responds to ping messages - `on_mention`: Handles direct mentions - `on_message`: Processes incoming messages ### Additional Information - For detailed logging, include `logging.basicConfig(level=logging.DEBUG)` in your code. - The bot is designed to automatically reconnect in case of connection drops. - Feel free to customize the bot to meet your specific requirements. ### Contribution Guidelines Contributions are welcome. Please submit pull requests for any enhancements or bug fixes. ### License This project is licensed under the MIT License.