Skip to content
Snippets Groups Projects
Commit 687fba91 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Implement funcionality

parent 30c8004d
No related branches found
No related tags found
No related merge requests found
from subprocess import CalledProcessError, check_output
from mycroft import MycroftSkill, intent_file_handler from mycroft import MycroftSkill, intent_file_handler
...@@ -7,13 +9,25 @@ class Wtf(MycroftSkill): ...@@ -7,13 +9,25 @@ class Wtf(MycroftSkill):
@intent_file_handler('wtf.intent') @intent_file_handler('wtf.intent')
def handle_wtf(self, message): def handle_wtf(self, message):
acronym = message.data.get('acronym') acronym = message.data.get('acronym').upper()
definitions = ''
try:
output = check_output(['wtf', acronym]).decode('utf-8')
except CalledProcessError:
self.speak_dialog('gee', data={
'acronym': acronym
})
else:
definitions = []
for line in output.split('\n'):
line = line.replace('%s:' % acronym, '').strip()
if line:
definitions.append(line)
self.speak_dialog('wtf', data={ self.speak_dialog('wtf', data={
'definitions': definitions, 'definitions': ', '.join(definitions),
'acronym': acronym 'acronym': acronym
}) })
def create_skill(): def create_skill():
......
Gee, I don’t know what "{acronym}" means.
{{acronym}} means {{definitions}} {acronym} means {definitions}
Wtf is {{acronym}} ( wtf | what the fuck ) is {acronym}
What the fuck is {{acronym}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment