mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-26 04:51:08 -05:00
Wikifetch: add command for parsing any wiki
This commit is contained in:
parent
a5b453baf3
commit
5a1265f6b2
@ -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
|
||||
|
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user