Compare commits

...

2 Commits

Author SHA1 Message Date
8030955f3f Updated version. 2025-02-10 23:09:59 +01:00
a2b1d3c3aa Made doc changes. 2025-02-10 22:31:02 +01:00
3 changed files with 4 additions and 4 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())

View File

@ -11,7 +11,7 @@ authors = [
{ name = "retoor", email = "retoor@molodetz.nl" } { name = "retoor", email = "retoor@molodetz.nl" }
] ]
keywords = ["chat", "snek", "molodetz","bot"] keywords = ["chat", "snek", "molodetz","bot"]
requires-python = ">=3.12" requires-python = ">=3"
dependencies = [ dependencies = [
"aiohttp" "aiohttp"
] ]