Wikifetch: add command for parsing any wiki

This commit is contained in:
James Lu 2023-04-03 20:54:06 -07:00
parent a5b453baf3
commit 5a1265f6b2
2 changed files with 24 additions and 0 deletions

View File

@ -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):
"""<site base URL> <title>
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

View File

@ -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')