From f406a7a9566cd2e819cd9d20e71afbba3cbd71a3 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 10 Aug 2005 13:05:04 +0000 Subject: [PATCH] supybot plugin. whitespace is syntax with this one, Mike :) git-svn-id: svn://svn.open-ils.org/ILS/trunk@1628 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/Evergreen.py | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Open-ILS/src/extras/Evergreen.py diff --git a/Open-ILS/src/extras/Evergreen.py b/Open-ILS/src/extras/Evergreen.py new file mode 100644 index 0000000000..420eca7409 --- /dev/null +++ b/Open-ILS/src/extras/Evergreen.py @@ -0,0 +1,61 @@ +""" +Evergreen IRC Interface plugin for supybot +""" + +import supybot + +import urllib +import xml.dom.minidom +import re + +__revision__ = "$Id$" +__author__ = 'PINES' +__contributors__ = {} + +import supybot.conf as conf +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.ircmsgs as ircmsgs +import supybot.privmsgs as privmsgs +import supybot.registry as registry +import supybot.callbacks as callbacks + +def configure(advanced): + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('Evergreen', True) + +conf.registerPlugin('Evergreen') + +class Evergreen(callbacks.PrivmsgCommandAndRegexp): + threaded = True + def __init__(self): + self.__parent = super(Evergreen, self) + self.__parent.__init__() + #super(Evergreen, self).__init__() + + def callCommand(self, name, irc, msg, *L, **kwargs): + self.__parent.callCommand(name, irc, msg, *L, **kwargs) + + def osearch(self, irc, msg, args, word): + """ + + Performs an OpenSearch against Evergreen for . + """ + url = 'http://192.168.2.112/opensearch/?target=mr_result&mr_search_type=keyword&mr_search_query=' + urllib.quote(word) + '&page=1&mr_search_depth=0&mr_search_location=1&pagesize=5&max_rank=100' + irc.reply( 'Searching for ' + word + '...' ); + rss = urllib.urlopen( url ) + dom = xml.dom.minidom.parseString( rss.read() ) + regexp = re.compile(r'http://tinyurl.com/\w+'); + for item in dom.getElementsByTagName('item'): + title = item.getElementsByTagName('title')[0] + link = item.getElementsByTagName('link')[0] + f = urllib.urlopen('http://tinyurl.com/create.php?url='+link.firstChild.data) + tiny = regexp.search( f.read() ).group(0) + s = title.firstChild.data + s += " | " + tiny + irc.reply( s ) + + osearch = wrap(osearch, ['Text']) +Class = Evergreen -- 2.43.2