Update.
This commit is contained in:
parent
25a5eca313
commit
1857f18d3d
76
README.md
76
README.md
@ -1,83 +1,81 @@
|
|||||||
# π SnekBot: Your Instant Chat Companion π
|
# SnekBot: Your Instant Chat Companion
|
||||||
|
|
||||||
## π₯ Create Your Own Bot in 5 Minutes Flat!
|
## Create Your Own Bot in Minutes
|
||||||
|
|
||||||
### Why SnekBot?
|
### Overview
|
||||||
- π¨ Lightning-fast setup
|
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.
|
||||||
- π€ Fully async and production-ready
|
|
||||||
- π Super flexible and easy to customize
|
|
||||||
- π‘οΈ Handles network issues like a boss
|
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
- Python 3.8+ (because we're modern like that)
|
- Python 3.8 or higher
|
||||||
- A sense of adventure π΄ββ οΈ
|
- Basic understanding of Python programming
|
||||||
|
|
||||||
### Quick Installation Magic β¨
|
### Installation Instructions
|
||||||
|
|
||||||
#### 1. Prep Your Environment
|
#### 1. Prepare Your Environment
|
||||||
```bash
|
```bash
|
||||||
# Ubuntu/Debian users, get ready!
|
# For Ubuntu/Debian users:
|
||||||
sudo apt install python3 python3-venv python3-pip -y
|
sudo apt install python3 python3-venv python3-pip -y
|
||||||
|
|
||||||
# Create your bot's magical realm
|
# Create a virtual environment for your bot
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 2. Summon SnekBot
|
#### 2. Install SnekBot
|
||||||
```bash
|
```bash
|
||||||
pip install git+https://molodetz.nl/retoor/snekbot.git
|
pip install git+https://molodetz.nl/retoor/snekbot.git
|
||||||
```
|
```
|
||||||
|
|
||||||
### π€ Bot Creation Wizard
|
### Bot Development
|
||||||
|
To create your bot, use the following template:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
from snekbot.bot import Bot
|
from snekbot.bot import Bot
|
||||||
|
|
||||||
class CoolSnekBot(Bot):
|
class CustomSnekBot(Bot):
|
||||||
async def on_join(self, channel_uid):
|
async def on_join(self, channel_uid):
|
||||||
await self.send_message(
|
await self.send_message(
|
||||||
channel_uid,
|
channel_uid,
|
||||||
"Yo! I'm here to make this chat awesome! π"
|
"Hello! I am here to assist you."
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_message(self, sender_username, sender_nick, channel_uid, message):
|
async def on_message(self, sender_username, sender_nick, channel_uid, message):
|
||||||
message = message.lower()
|
message = message.lower()
|
||||||
if "hello" in message:
|
if "hello" in message:
|
||||||
await self.send_message(channel_uid, f"Hi there, {sender_nick}! π")
|
await self.send_message(channel_uid, f"Greetings, {sender_nick}!")
|
||||||
elif "bye" in message:
|
elif "bye" in message:
|
||||||
await self.send_message(channel_uid, f"Catch you later, {sender_nick}! π€")
|
await self.send_message(channel_uid, f"Goodbye, {sender_nick}!")
|
||||||
|
|
||||||
# Launch your bot into the wild!
|
# Initialize your bot
|
||||||
bot = CoolSnekBot(
|
bot = CustomSnekBot(
|
||||||
url="wss://your-snek-instance.com/rpc.ws",
|
url="wss://your-snek-instance.com/rpc.ws",
|
||||||
username="your_awesome_bot",
|
username="your_bot_username",
|
||||||
password="super_secret_password"
|
password="your_secure_password"
|
||||||
)
|
)
|
||||||
asyncio.run(bot.run())
|
asyncio.run(bot.run())
|
||||||
```
|
```
|
||||||
|
|
||||||
### π Run Your Bot
|
### Running Your Bot
|
||||||
```bash
|
```bash
|
||||||
python your_awesome_bot.py
|
python your_bot_script.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### Event Handlers You Can Override
|
### Event Handlers
|
||||||
- `on_join`: When bot enters a channel
|
You can override the following event handlers:
|
||||||
- `on_leave`: When bot exits a channel
|
- `on_join`: Triggered when the bot joins a channel
|
||||||
- `on_ping`: Respond to ping messages
|
- `on_leave`: Triggered when the bot leaves a channel
|
||||||
- `on_mention`: Handle direct mentions
|
- `on_ping`: Responds to ping messages
|
||||||
- `on_message`: Catch and respond to general messages
|
- `on_mention`: Handles direct mentions
|
||||||
|
- `on_message`: Processes incoming messages
|
||||||
|
|
||||||
### π‘ Pro Tips
|
### Additional Information
|
||||||
- Add `logging.basicConfig(level=logging.DEBUG)` for detailed logs
|
- For detailed logging, include `logging.basicConfig(level=logging.DEBUG)` in your code.
|
||||||
- The bot automatically reconnects if connection drops
|
- The bot is designed to automatically reconnect in case of connection drops.
|
||||||
- Customize to your heart's content!
|
- Feel free to customize the bot to meet your specific requirements.
|
||||||
|
|
||||||
### Contributing
|
### Contribution Guidelines
|
||||||
Got cool ideas? PRs are welcome! π€
|
Contributions are welcome. Please submit pull requests for any enhancements or bug fixes.
|
||||||
|
|
||||||
### License
|
### License
|
||||||
MIT - Go wild, have fun! π
|
This project is licensed under the MIT License.
|
||||||
|
|
Loadingβ¦
Reference in New Issue
Block a user