Don't explode when function doesn't get implemented

Closes https://git.autonomic.zone/decentral1se/xbotlib/issues/18.
This commit is contained in:
Luke Murphy 2021-01-14 19:34:13 +01:00
parent 87ada3e79d
commit fbd72b55fe
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,9 @@
# xbotlib x.x.x (UNRELEASED)
# xbotlib 0.8.0 (2021-01-14)
- Support not providing response implementation ([#18](https://git.autonomic.zone/decentral1se/xbotlib/issues/18))
# xbotlib 0.7.1 (2021-01-13)
- Support logging ([#2](https://git.autonomic.zone/decentral1se/xbotlib/issues/2))

View File

@ -138,7 +138,10 @@ class Bot(ClientXMPP):
def direct_message(self, message):
"""Handle message event."""
if message["type"] in ("chat", "normal"):
self.direct(SimpleMessage(message))
try:
self.direct(SimpleMessage(message))
except AttributeError:
self.log.info("Bot.direct not implemented")
def session_start(self, message):
"""Handle session_start event."""
@ -155,7 +158,10 @@ class Bot(ClientXMPP):
"""Handle groupchat_message event."""
if message["type"] in ("groupchat", "normal"):
if message["mucnick"] != self.config["bot"]["nick"]:
self.group(SimpleMessage(message))
try:
self.group(SimpleMessage(message))
except AttributeError:
self.log.info("Bot.group not implemented")
def register_xmpp_plugins(self):
"""Register XMPP plugins that the bot supports."""