f10e2ce7b2a8d8a5b3037fa1b4c87d6d962cfc48
π SnekBot: Your Instant Chat Companion π
π₯ Create Your Own Bot in 5 Minutes Flat!
Why SnekBot?
- π¨ Lightning-fast setup
- π€ Fully async and production-ready
- π Super flexible and easy to customize
- π‘οΈ Handles network issues like a boss
Prerequisites
- Python 3.8+ (because we're modern like that)
- A sense of adventure π΄ββ οΈ
Quick Installation Magic β¨
1. Prep Your Environment
# Ubuntu/Debian users, get ready!
sudo apt install python3 python3-venv python3-pip -y
# Create your bot's magical realm
python3 -m venv venv
source venv/bin/activate
2. Summon SnekBot
pip install git+https://molodetz.nl/retoor/snekbot.git
π€ Bot Creation Wizard
import asyncio
from snekbot.bot import Bot
class CoolSnekBot(Bot):
async def on_join(self, channel_uid):
await self.send_message(
channel_uid,
"Yo! I'm here to make this chat awesome! π"
)
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"Hi there, {sender_nick}! π")
elif "bye" in message:
await self.send_message(channel_uid, f"Catch you later, {sender_nick}! π€")
# Launch your bot into the wild!
bot = CoolSnekBot(
url="wss://your-snek-instance.com/rpc.ws",
username="your_awesome_bot",
password="super_secret_password"
)
asyncio.run(bot.run())
π Run Your Bot
python your_awesome_bot.py
Event Handlers You Can Override
on_join: When bot enters a channelon_leave: When bot exits a channelon_ping: Respond to ping messageson_mention: Handle direct mentionson_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!
Contributing
Got cool ideas? PRs are welcome! π€
License
MIT - Go wild, have fun! π
Description
The snek bot API. Use this to create a snek bot withing minutes! With nice example. The tutorial of creating a snek bot is just a few lines and a code snippet!
304 KiB
Languages
Python
98.9%
Makefile
1.1%