mirror of https://github.com/Mikaela/Limnoria.git
Update to use irc.replies so that people can take advantage of
conf.supybot.reply.oneToOne
This commit is contained in:
parent
e69f086b51
commit
23f4dc2d0f
|
@ -79,7 +79,7 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp):
|
||||||
threaded = True
|
threaded = True
|
||||||
callBefore = ['URL']
|
callBefore = ['URL']
|
||||||
regexps = ['geekSnarfer']
|
regexps = ['geekSnarfer']
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__parent = super(Geekquote, self)
|
self.__parent = super(Geekquote, self)
|
||||||
self.__parent.__init__()
|
self.__parent.__init__()
|
||||||
|
@ -95,9 +95,10 @@ 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>',
|
||||||
re.M | re.DOTALL),
|
re.M | re.DOTALL),
|
||||||
'qdb.us':re.compile(_qdbReString, re.M | re.DOTALL)}
|
'qdb.us':re.compile(_qdbReString, re.M | re.DOTALL)}
|
||||||
def _gkBackend(self, irc, msg, site, id):
|
def _gkBackend(self, irc, msg, site, id):
|
||||||
|
@ -116,13 +117,13 @@ class Geekquote(callbacks.PrivmsgCommandAndRegexp):
|
||||||
if self.randomData[site]:
|
if self.randomData[site]:
|
||||||
quote = self.randomData[site].pop()
|
quote = self.randomData[site].pop()
|
||||||
else:
|
else:
|
||||||
if (site == 'qdb.us' and
|
if (site == 'qdb.us' and
|
||||||
int(time.time()) - self.lastqdbRandomTime <= 90):
|
int(time.time()) - self.lastqdbRandomTime <= 90):
|
||||||
id = 'browse=%s' % fix.choice(range(self.maxqdbPages))
|
id = 'browse=%s' % fix.choice(range(self.maxqdbPages))
|
||||||
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]:
|
||||||
|
|
Loading…
Reference in New Issue