Compare commits
2 Commits
636ea209d1
...
8030955f3f
| Author | SHA1 | Date | |
|---|---|---|---|
| 8030955f3f | |||
| a2b1d3c3aa |
@ -29,7 +29,7 @@ Make sure you have this information right now:
|
||||
- bot url (wss://your-snek-instance.com/rpc.ws)
|
||||
|
||||
#### Create a file
|
||||
Open a file ending with the `.py` extension and pase this content.
|
||||
Open a file ending with the `.py` extension and paste this content. Replace the authentication details on the bottom lines with the one of the account you just created.
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
@ -120,6 +120,6 @@ The `ExampleBot` class inherits from a base `Bot` class and implements several e
|
||||
- `on_own_message`: Logs messages sent by the bot itself.
|
||||
- `on_mention`: Handles mentions; if "source" is in the message, it replies with its own source code, with sensitive data disguised.
|
||||
- `on_message`: Responds to "hello" and "bye" messages if the bot has joined the channel.
|
||||
The bot will be instantiated and runs asynchronously.
|
||||
The bot will be instantiated and runs asynchronously. It will survive server deploys and network outages. If such issue occurs, it will try to reconnect within a second like nothing happened. It's production ready.
|
||||
|
||||
|
||||
|
||||
@ -67,5 +67,5 @@ class ExampleBot(Bot):
|
||||
await self.send_message(channel_uid, result)
|
||||
|
||||
|
||||
bot = ExampleBot(url="ws://snek.molodetz.nl/rpc.ws", username="example", password="example")
|
||||
bot = ExampleBot(url="ws://snek.molodetz.nl/rpc.ws", username="example", password="xxxxxx")
|
||||
asyncio.run(bot.run())
|
||||
|
||||
@ -11,7 +11,7 @@ authors = [
|
||||
{ name = "retoor", email = "retoor@molodetz.nl" }
|
||||
]
|
||||
keywords = ["chat", "snek", "molodetz","bot"]
|
||||
requires-python = ">=3.12"
|
||||
requires-python = ">=3"
|
||||
dependencies = [
|
||||
"aiohttp"
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user