1 Star 0 Fork 0

wukong/mycroft-skills

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
__init__.py 2.76 KB
一键复制 编辑 原始数据 按行查看 历史
penrods 提交于 2018-02-19 18:26 +08:00 . Rework of the template to reflect modern practices
# TODO: Add an appropriate license to your skill before publishing. See
# the LICENSE file for more information.
# Below is the list of outside modules you'll be using in your skill.
# They might be built-in to Python, from mycroft-core or from external
# libraries. If you use an external library, be sure to include it
# in the requirements.txt file so the library is installed properly
# when the skill gets installed later by a user.
from adapt.intent import IntentBuilder
from mycroft.skills.core import MycroftSkill, intent_handler
from mycroft.util.log import LOG
# Each skill is contained within its own class, which inherits base methods
# from the MycroftSkill class. You extend this class as shown below.
# TODO: Change "Template" to a unique name for your skill
class TemplateSkill(MycroftSkill):
# The constructor of the skill, which calls MycroftSkill's constructor
def __init__(self):
super(TemplateSkill, self).__init__(name="TemplateSkill")
# Initialize working variables used within the skill.
self.count = 0
# The "handle_xxxx_intent" function is triggered by Mycroft when the
# skill's intent is matched. The intent is defined by the IntentBuilder()
# pieces, and is triggered when the user's utterance matches the pattern
# defined by the keywords. In this case, the match occurs when one word
# is found from each of the files:
# vocab/en-us/Hello.voc
# vocab/en-us/World.voc
# In this example that means it would match on utterances like:
# 'Hello world'
# 'Howdy you great big world'
# 'Greetings planet earth'
@intent_handler(IntentBuilder("").require("Hello").require("World"))
def handle_hello_world_intent(self, message):
# In this case, respond by simply speaking a canned response.
# Mycroft will randomly speak one of the lines from the file
# dialogs/en-us/hello.world.dialog
self.speak_dialog("hello.world")
@intent_handler(IntentBuilder("").require("Count").require("Dir"))
def handle_count_intent(self, message):
if message.data["Dir"] == "up":
self.count += 1
else: # assume "down"
self.count -= 1
self.speak_dialog("count.is.now", data={"count": self.count})
# The "stop" method defines what Mycroft does when told to stop during
# the skill's execution. In this case, since the skill's functionality
# is extremely simple, there is no need to override it. If you DO
# need to implement stop, you should return True to indicate you handled
# it.
#
# def stop(self):
# return False
# The "create_skill()" method is used to create an instance of the skill.
# Note that it's outside the class itself.
def create_skill():
return TemplateSkill()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ahuachen/mycroft-skills.git
git@gitee.com:ahuachen/mycroft-skills.git
ahuachen
mycroft-skills
mycroft-skills
17.08-and-older

搜索帮助