Skip to content

Commit

Permalink
Update add_event patching to work around FakeBus compat. (#490)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Dec 15, 2023
1 parent 64a0d71 commit 2ad43bb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions neon_utils/skills/neon_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,17 @@ def add_event(self, name: str, handler: callable,
handler_info: Optional[str] = None, once: bool = False,
speak_errors: bool = True):
# TODO: Remove with ovos-workshop==0.0.13
if handler_info == "mycroft.skill.handler" and \
self.bus.emitter.listeners(name):
LOG.warning(f"Not re-registering intent handler {name}")
return
try:
# Patching FakeBus compat. with MessageBusClient
if hasattr(self.bus, "ee"):
emitter = self.bus.ee
else:
emitter = self.bus.emitter
if handler_info == "mycroft.skill.handler" and \
emitter.listeners(name):
LOG.warning(f"Not re-registering intent handler {name}")
return
except Exception as e:
LOG.exception(e)
BaseSkill.add_event(self, name, handler, handler_info, once,
speak_errors)

0 comments on commit 2ad43bb

Please sign in to comment.