diff --git a/Wikifetch/plugin.py b/Wikifetch/plugin.py index 146539d..cca9596 100644 --- a/Wikifetch/plugin.py +++ b/Wikifetch/plugin.py @@ -162,4 +162,19 @@ class Wikifetch(callbacks.Plugin): baseurl = f'https://{wiki_subdomain}.wiki.gg/api.php' self._wiki(irc, baseurl, searchquery) + @wrap(['somethingWithoutSpaces', 'text']) + def customwiki(self, irc, msg, args, baseurl, searchquery): + """ + + Returns the first paragraph of a page on MediaWiki powered site of your choice. + + This requires the URL of your desired wiki's API URL: usually you can find this by opening the Source code of + any wiki page and looking for links ending with `api.php`. + """ + if '://' not in baseurl: + baseurl = 'https://' + baseurl + if not baseurl.lower().endswith('/api.php'): + baseurl += '/api.php' + self._wiki(irc, baseurl, searchquery) + Class = Wikifetch diff --git a/Wikifetch/test.py b/Wikifetch/test.py index 5d7ea3e..7baa944 100644 --- a/Wikifetch/test.py +++ b/Wikifetch/test.py @@ -174,3 +174,12 @@ if network: def testWikigg(self): self.assertRegexp('wikigg terraria Ocean', r'Ocean.*biome') + + def testCustomArchWiki(self): + self.assertRegexp('customwiki https://wiki.archlinux.org/api.php KDE', + r'KDE is.*desktop') + + def testCustomParadoxWikis(self): + # api.php will be appended if not present + self.assertRegexp('customwiki https://skylines.paradoxwikis.com/ Zoning', + r'Zones.*buildings')