Made doc changes.

This commit is contained in:
retoor 2025-02-10 22:31:02 +01:00
parent 636ea209d1
commit a2b1d3c3aa
2 changed files with 3 additions and 3 deletions

View File

@ -29,7 +29,7 @@ Make sure you have this information right now:
- bot url (wss://your-snek-instance.com/rpc.ws) - bot url (wss://your-snek-instance.com/rpc.ws)
#### Create a file #### 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 ```python
import asyncio 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_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_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. - `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.

View File

@ -67,5 +67,5 @@ class ExampleBot(Bot):
await self.send_message(channel_uid, result) 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()) asyncio.run(bot.run())