Update to use irc.replies so that people can take advantage of

conf.supybot.reply.oneToOne
This commit is contained in:
James Vega 2004-10-05 07:24:49 +00:00
parent e69f086b51
commit 23f4dc2d0f

View File

@ -95,6 +95,7 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp):
except webutils.WebError, e: except webutils.WebError, e:
irc.error(str(e)) irc.error(str(e))
_joiner = ' // '
_qdbReString = r'<tr><td bgcolor="#(?:ffffff|e8e8e8)"><a href="/\d*?">'\ _qdbReString = r'<tr><td bgcolor="#(?:ffffff|e8e8e8)"><a href="/\d*?">'\
r'#\d*?</a>.*?<p>(?P<text>.*?)</p></td></tr>' r'#\d*?</a>.*?<p>(?P<text>.*?)</p></td></tr>'
_gkREDict = {'bash.org':re.compile(r'<p class="qt">(?P<text>.*?)</p>', _gkREDict = {'bash.org':re.compile(r'<p class="qt">(?P<text>.*?)</p>',
@ -122,7 +123,7 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp):
quote = self._gkFetchData(site, id, random=True) quote = self._gkFetchData(site, id, random=True)
else: else:
quote = self._gkFetchData(site, id) quote = self._gkFetchData(site, id)
irc.reply(quote) irc.replies(quote.split(self._joiner), joiner=self._joiner)
def _gkFetchData(self, site, id, random=False): def _gkFetchData(self, site, id, random=False):
html = '' html = ''
@ -131,10 +132,9 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp):
except webutils.WebError, e: except webutils.WebError, e:
self.log.info('%s server returned the error: %s' % \ self.log.info('%s server returned the error: %s' % \
(site, webutils.strError(e))) (site, webutils.strError(e)))
s = ''
for item in self._gkREDict[site].finditer(html): for item in self._gkREDict[site].finditer(html):
s = item.groupdict()['text'] s = item.groupdict()['text']
s = ' // '.join(s.splitlines()) s = self._joiner.join(s.splitlines())
s = utils.htmlToText(s) s = utils.htmlToText(s)
if random and s: if random and s:
if s not in self.randomData[site]: if s not in self.randomData[site]: