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
......@@ -7,13 +9,25 @@ class Wtf(MycroftSkill):
@intent_file_handler('wtf.intent')
def handle_wtf(self, message):
acronym = message.data.get('acronym')
definitions = ''
acronym = message.data.get('acronym').upper()
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={
'definitions': definitions,
'acronym': acronym
})
self.speak_dialog('wtf', data={
'definitions': ', '.join(definitions),
'acronym': acronym
})
def create_skill():
......
Gee, I don’t know what "{acronym}" means.
{{acronym}} means {{definitions}}
{acronym} means {definitions}
Wtf is {{acronym}}
What the fuck is {{acronym}}
( wtf | what the fuck ) is {acronym}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment