Add setup
Closes https://git.autonomic.zone/decentral1se/xbotlib/issues/36.
This commit is contained in:
parent
dd40939cbf
commit
6a30078351
|
@ -1,5 +1,9 @@
|
|||
# xbotlib x.x.x (UNRELEASED)
|
||||
|
||||
# xbotlib x.x.x (UNRELEASED)
|
||||
|
||||
- Add `setup` function hook ([#36](https://git.autonomic.zone/decentral1se/xbotlib/issues/36))
|
||||
|
||||
# xbotlib 0.15.1 (2021-01-24)
|
||||
|
||||
- Save to file based storage on all writes ([#39](https://git.autonomic.zone/decentral1se/xbotlib/issues/39))
|
||||
|
|
|
@ -25,6 +25,7 @@ you want to chat or just invite your bots for testing.
|
|||
- [Bot.direct(message)](#bot-direct-message)
|
||||
- [Bot.group(message)](#bot-group-message)
|
||||
- [Bot.serve(request)](#bot-serve-request)
|
||||
- [Bot.setup()](#bot-setup)
|
||||
- [SimpleMessage](#simplemessage)
|
||||
- [Bot](#bot)
|
||||
- [Working with your bot](#working-with-your-bot)
|
||||
|
@ -114,6 +115,10 @@ Arguments:
|
|||
|
||||
- **request**: the web request
|
||||
|
||||
### Bot.setup()
|
||||
|
||||
Run some setup logic before starting your bot.
|
||||
|
||||
### SimpleMessage
|
||||
|
||||
A simple message interface.
|
||||
|
|
|
@ -673,6 +673,15 @@ class Bot(ClientXMPP):
|
|||
if self.serve:
|
||||
self.log.info("Turning on the web server")
|
||||
self.serve_web()
|
||||
|
||||
if hasattr(self, "setup"):
|
||||
try:
|
||||
self.setup()
|
||||
self.log.info("Finished running Bot.setup")
|
||||
except Exception as exception:
|
||||
message = f"Bot.setup failed: {exception}"
|
||||
self.log.info(message)
|
||||
|
||||
self.process(forever=False)
|
||||
except (KeyboardInterrupt, RuntimeError):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue