Skip to content

Commit

Permalink
v.0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Feb 26, 2021
1 parent 866ab90 commit 7f3074f
Show file tree
Hide file tree
Showing 148 changed files with 101 additions and 364 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# <img src='https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/brands/wikipedia-w.svg' card_color='#000000' width='50' height='50' style='vertical-align:bottom'/> Wikipedia
Wikipedia

![](./logo.png)

## About
Query [Wikipedia](https://www.wikipedia.org) for answers to all your questions. Get just a summary, or ask for more to get in-depth information.

This Skill uses the [Wikipedia for humans](https://github.com/HelloChatterbox/wikipedia_for_humans).

NOTE: this will blacklist the official mycroft skill

![](./gui.gif)

## Examples
* "Tell me about Elon Musk"
* "Tell me about beans"
Expand Down
47 changes: 25 additions & 22 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,25 @@
from mycroft.skills.core import (MycroftSkill, intent_handler,
intent_file_handler)
from mycroft.messagebus.message import Message
from mycroft.configuration import LocalConf, USER_CONFIG,Configuration
from ovos_utils.skills import blacklist_skill


class WikipediaSkill(MycroftSkill):
def __init__(self):
super(WikipediaSkill, self).__init__(name="WikipediaSkill")
self.idx = 0
self.results = []
self.current_picture = None
self.current_title = None

def initialize(self):
self.blacklist_default_skill()
blacklist_skill("mycroft-wiki.mycroftai")

def blacklist_default_skill(self):
core_conf = Configuration.load_config_stack()
blacklist = core_conf["skills"]["blacklisted_skills"]
if "mycroft-wiki.mycroftai" not in blacklist:
self.log.debug("Blacklisting official mycroft wikipedia skill")
blacklist.append("mycroft-wiki.mycroftai")
conf = LocalConf(USER_CONFIG)
if "skills" not in conf:
conf["skills"] = {}
conf["skills"]["blacklisted_skills"] = blacklist
conf.store()

self.bus.emit(Message("detach_skill",
{"skill_id": "mycroft-wiki.mycroftai"}))
def display_wiki_entry(self):
if self.current_picture and len(self.current_picture):
self.gui.show_image(self.current_picture[0],
title=self.current_title, fill=None,
override_idle=20, override_animations=True)

def speak_result(self):
if self.idx + 1 > len(self.results):
Expand All @@ -51,22 +44,27 @@ def speak_result(self):
self.speak(self.results[self.idx])
self.idx += 1
self.set_context("Wikipedia", "wikipedia")
self.display_wiki_entry()

@intent_handler(IntentBuilder("WikiSearch").require("Wikipedia").
require("ArticleTitle"))
@intent_handler("wiki.intent")
def handle_wiki_query(self, message):
""" Extract what the user asked about and reply with info
from wikipedia.
"""
search = message.data.get("query")
self.current_picture = None
self.current_title = search
# Talk to the user, as this can take a little time...
search = message.data.get("ArticleTitle")
self.speak_dialog("searching", {"query": search})
if "lang" in self.settings:
lang = self.settings["lang"]
else:
lang = self.lang.split("-")[0]
try:
answer = wikipedia_for_humans.summary(search, lang=lang)
data = wikipedia_for_humans.page_data(search, lang=lang)
self.current_picture = data["images"]
self.current_title = data["title"]
answer = data["summary"]
if not answer.strip():
self.speak_dialog("no entry found")
return
Expand All @@ -78,10 +76,10 @@ def handle_wiki_query(self, message):
except ConnectionError as e:
self.log.error("It seems like lang is invalid!!!")
self.log.error(lang + ".wikipedia.org does not seem to exist")
self.log.info("Override this in skill settings")
self.log.info("Override 'lang' in skill settings")
# TODO dialog
# TODO Settings meta
raise e # just speak regular error
raise e # just speak regular skill error

@intent_handler(IntentBuilder("WikiMore").require("More").
require("wiki_article"))
Expand All @@ -93,6 +91,11 @@ def handle_tell_more(self, message):
"""
self.speak_result()

def stop(self):
self.gui.release()


def create_skill():
return WikipediaSkill()


2 changes: 0 additions & 2 deletions dialog/ca-es/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ca-es/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/ca-es/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/ca-es/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ca-es/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ca-es/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/da-dk/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/da-dk/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/da-dk/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/da-dk/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/da-dk/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/da-dk/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/de-de/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/de-de/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/de-de/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/de-de/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/de-de/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/de-de/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/el-gr/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/el-gr/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/el-gr/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/el-gr/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/el-gr/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/el-gr/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/en-us/disambiguate.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/en-us/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/en-us/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/en-us/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-es/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-es/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/es-es/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/es-es/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-es/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-es/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-lm/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-lm/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/es-lm/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/es-lm/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-lm/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/es-lm/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/fr-fr/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/fr-fr/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/fr-fr/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/fr-fr/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/fr-fr/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/fr-fr/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/gl-es/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/gl-es/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/gl-es/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/gl-es/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/gl-es/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/gl-es/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/it-it/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/it-it/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/it-it/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/it-it/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/it-it/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/it-it/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/nl-nl/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/nl-nl/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/nl-nl/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/nl-nl/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/nl-nl/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/nl-nl/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pl-pl/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pl-pl/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/pl-pl/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/pl-pl/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pl-pl/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pl-pl/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-br/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-br/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/pt-br/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/pt-br/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-br/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-br/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-pt/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-pt/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/pt-pt/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/pt-pt/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-pt/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/pt-pt/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ro-ro/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ro-ro/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/ro-ro/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/ro-ro/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ro-ro/thats all.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ro-ro/wikipedia_lang.value

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ru-ru/disambiguate.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ru-ru/no entry found.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/ru-ru/or.dialog

This file was deleted.

3 changes: 0 additions & 3 deletions dialog/ru-ru/searching.dialog

This file was deleted.

2 changes: 0 additions & 2 deletions dialog/ru-ru/thats all.dialog

This file was deleted.

Loading

0 comments on commit 7f3074f

Please sign in to comment.