From 23f4dc2d0f012b2b8ad0f6dcc33a4feb5330331b Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 5 Oct 2004 07:24:49 +0000 Subject: [PATCH] Update to use irc.replies so that people can take advantage of conf.supybot.reply.oneToOne --- plugins/Geekquote.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/Geekquote.py b/plugins/Geekquote.py index eefd57e4d..9e33c048c 100644 --- a/plugins/Geekquote.py +++ b/plugins/Geekquote.py @@ -79,7 +79,7 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp): threaded = True callBefore = ['URL'] regexps = ['geekSnarfer'] - + def __init__(self): self.__parent = super(Geekquote, self) self.__parent.__init__() @@ -95,9 +95,10 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp): except webutils.WebError, e: irc.error(str(e)) + _joiner = ' // ' _qdbReString = r''\ r'#\d*?.*?

(?P.*?)

' - _gkREDict = {'bash.org':re.compile(r'

(?P.*?)

', + _gkREDict = {'bash.org':re.compile(r'

(?P.*?)

', re.M | re.DOTALL), 'qdb.us':re.compile(_qdbReString, re.M | re.DOTALL)} def _gkBackend(self, irc, msg, site, id): @@ -116,13 +117,13 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp): if self.randomData[site]: quote = self.randomData[site].pop() else: - if (site == 'qdb.us' and + if (site == 'qdb.us' and int(time.time()) - self.lastqdbRandomTime <= 90): id = 'browse=%s' % fix.choice(range(self.maxqdbPages)) quote = self._gkFetchData(site, id, random=True) else: quote = self._gkFetchData(site, id) - irc.reply(quote) + irc.replies(quote.split(self._joiner), joiner=self._joiner) def _gkFetchData(self, site, id, random=False): html = '' @@ -131,10 +132,9 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp): except webutils.WebError, e: self.log.info('%s server returned the error: %s' % \ (site, webutils.strError(e))) - s = '' for item in self._gkREDict[site].finditer(html): s = item.groupdict()['text'] - s = ' // '.join(s.splitlines()) + s = self._joiner.join(s.splitlines()) s = utils.htmlToText(s) if random and s: if s not in self.randomData[site]: