2010-12-21 00:22:25 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
vtluugwiki.py - Phenny VTLUUG Wiki Module
|
|
|
|
Copyright 2008-9, Sean B. Palmer, inamidst.com
|
|
|
|
Licensed under the Eiffel Forum License 2.
|
|
|
|
|
|
|
|
http://inamidst.com/phenny/
|
|
|
|
|
|
|
|
modified from Wikipedia module
|
2012-01-03 14:09:34 -05:00
|
|
|
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
2010-12-21 00:22:25 -05:00
|
|
|
"""
|
|
|
|
|
2012-06-14 00:58:31 -04:00
|
|
|
import wiki
|
2010-12-21 00:22:25 -05:00
|
|
|
|
2018-03-16 09:27:18 -04:00
|
|
|
endpoints = {
|
|
|
|
'api': 'https://vtluug.org/w/api.php?action=query&list=search&srsearch={0}&limit=1&prop=snippet&format=json',
|
|
|
|
'url': 'https://vtluug.org/wiki/{0}',
|
|
|
|
'search': 'https://vtluug.org/wiki/Special:Search?search={0}&fulltext=Search',
|
|
|
|
}
|
2010-12-21 00:22:25 -05:00
|
|
|
|
|
|
|
def vtluug(phenny, input):
|
2013-10-05 19:20:37 -04:00
|
|
|
""".vtluug <term> - Look up something on the VTLUUG wiki."""
|
|
|
|
|
2011-07-15 13:43:27 -04:00
|
|
|
origterm = input.groups()[1]
|
|
|
|
if not origterm:
|
2012-06-14 00:58:31 -04:00
|
|
|
return phenny.say('Perhaps you meant ".vtluug VT-Wireless"?')
|
2010-12-21 00:22:25 -05:00
|
|
|
|
2018-03-16 09:27:18 -04:00
|
|
|
term, section = wiki.parse_term(origterm)
|
2010-12-21 00:22:25 -05:00
|
|
|
|
2018-03-16 09:27:18 -04:00
|
|
|
w = wiki.Wiki(endpoints)
|
|
|
|
match = w.search(term)
|
2012-06-14 00:58:31 -04:00
|
|
|
|
2018-03-16 09:27:18 -04:00
|
|
|
if not match:
|
|
|
|
phenny.say('Can\'t find anything in the VTLUUG Wiki for "{0}".'.format(term))
|
|
|
|
return
|
|
|
|
|
|
|
|
snippet, url = wiki.extract_snippet(match, section)
|
|
|
|
|
|
|
|
phenny.say('"{0}" - {1}'.format(snippet, url))
|
2010-12-21 00:22:25 -05:00
|
|
|
|
|
|
|
vtluug.commands = ['vtluug']
|
|
|
|
vtluug.priority = 'high'
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2011-09-22 14:17:27 -04:00
|
|
|
print(__doc__.strip())
|