84 lines
2.1 KiB
Markdown
Raw Normal View History

2025-05-05 22:13:45 +02:00
# 🐍 SnekBot: Your Instant Chat Companion 🚀
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
## 🔥 Create Your Own Bot in 5 Minutes Flat!
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
### Why SnekBot?
- 💨 Lightning-fast setup
- 🤖 Fully async and production-ready
- 🌈 Super flexible and easy to customize
- 🛡️ Handles network issues like a boss
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
### Prerequisites
- Python 3.8+ (because we're modern like that)
- A sense of adventure 🏴‍☠️
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
### Quick Installation Magic ✨
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
#### 1. Prep Your Environment
```bash
# Ubuntu/Debian users, get ready!
sudo apt install python3 python3-venv python3-pip -y
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
# Create your bot's magical realm
python3 -m venv venv
source venv/bin/activate
```
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
#### 2. Summon SnekBot
```bash
pip install git+https://molodetz.nl/retoor/snekbot.git
```
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
### 🤖 Bot Creation Wizard
2025-02-01 15:58:18 +01:00
```python
2025-02-10 14:16:55 +01:00
import asyncio
2025-02-01 15:58:18 +01:00
from snekbot.bot import Bot
2025-05-05 22:13:45 +02:00
class CoolSnekBot(Bot):
2025-02-10 14:16:55 +01:00
async def on_join(self, channel_uid):
await self.send_message(
2025-04-24 21:03:12 +02:00
channel_uid,
2025-05-05 22:13:45 +02:00
"Yo! I'm here to make this chat awesome! 🎉"
2025-02-10 14:16:55 +01:00
)
2025-02-01 15:58:18 +01:00
2025-02-10 14:16:55 +01:00
async def on_message(self, sender_username, sender_nick, channel_uid, message):
message = message.lower()
if "hello" in message:
2025-05-05 22:13:45 +02:00
await self.send_message(channel_uid, f"Hi there, {sender_nick}! 👋")
2025-02-01 15:58:18 +01:00
elif "bye" in message:
2025-05-05 22:13:45 +02:00
await self.send_message(channel_uid, f"Catch you later, {sender_nick}! 🤙")
2025-02-01 15:58:18 +01:00
2025-05-05 22:13:45 +02:00
# Launch your bot into the wild!
bot = CoolSnekBot(
url="wss://your-snek-instance.com/rpc.ws",
username="your_awesome_bot",
password="super_secret_password"
2025-04-24 21:03:12 +02:00
)
2025-02-01 15:58:18 +01:00
asyncio.run(bot.run())
```
2025-05-05 22:13:45 +02:00
### 🚀 Run Your Bot
2025-02-01 15:58:18 +01:00
```bash
2025-05-05 22:13:45 +02:00
python your_awesome_bot.py
2025-02-01 15:58:18 +01:00
```
2025-02-10 14:16:55 +01:00
2025-05-05 22:13:45 +02:00
### Event Handlers You Can Override
- `on_join`: When bot enters a channel
- `on_leave`: When bot exits a channel
- `on_ping`: Respond to ping messages
- `on_mention`: Handle direct mentions
- `on_message`: Catch and respond to general messages
### 💡 Pro Tips
- Add `logging.basicConfig(level=logging.DEBUG)` for detailed logs
- The bot automatically reconnects if connection drops
- Customize to your heart's content!
2025-02-10 14:16:55 +01:00
2025-05-05 22:13:45 +02:00
### Contributing
Got cool ideas? PRs are welcome! 🤝
2025-02-10 14:16:55 +01:00
2025-05-05 22:13:45 +02:00
### License
MIT - Go wild, have fun! 🎈
2025-02-10 14:16:55 +01:00