Clarify return semantics

See https://git.vvvvvvaria.org/decentral1se/xbotlib/issues/6.
This commit is contained in:
Luke Murphy 2021-01-23 21:43:10 +01:00
parent 7618fee082
commit b3cb78776e
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 5 additions and 2 deletions

View File

@ -64,10 +64,10 @@ from xbotlib import Bot
class EchoBot(Bot):
def direct(self, message):
return self.reply(message.text, to=message.sender)
self.reply(message.text, to=message.sender)
def group(self, message):
return self.reply(message.content, room=message.room)
self.reply(message.content, room=message.room)
```
And then `python echo.py`. You will be asked a few questions in order to load
@ -332,6 +332,9 @@ def serve(self, request):
return self.respond(rendered)
```
Please note the use of the `return` keyword here. The `serve` function must
return a response that will be passed to the web server.
If you want to pass data from your `direct`/`group` functions to the `serve`
function, you'll need to make use of [some type of persistent
storage](#persistent-storage). Your `serve` function can read from the storage