Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Commit 66453cb

Browse files
authored
Merge pull request #1015 from azie-ginanjar/make_message_optional
make message parameter on intent handler optional ==== Tech Notes ==== intent handlers that don't use the message bus message no longer need to have the argument so a simple intent handler could be def handle_yahoo(self): self.speak('Yahoo')
2 parents 8420ec3 + 27dba0c commit 66453cb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

mycroft/skills/core.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
from mycroft.util.log import getLogger
3737
from mycroft.skills.settings import SkillSettings
3838

39+
from inspect import getargspec
40+
3941
__author__ = 'seanfitz'
4042

4143
skills_config = ConfigurationManager.instance().get("skills")
@@ -323,9 +325,19 @@ def wrapper(message):
323325
try:
324326
if need_self:
325327
# When registring from decorator self is required
326-
handler(self, message)
328+
if len(getargspec(handler).args) == 2:
329+
handler(self, message)
330+
elif len(getargspec(handler).args) == 1:
331+
handler(self)
332+
else:
333+
raise TypeError
327334
else:
328-
handler(message)
335+
if len(getargspec(handler).args) == 2:
336+
handler(message)
337+
elif len(getargspec(handler).args) == 1:
338+
handler()
339+
else:
340+
raise TypeError
329341
self.settings.store() # Store settings if they've changed
330342
except:
331343
# TODO: Localize

0 commit comments

Comments
 (0)