mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-12 05:02:32 +01:00
parent
ba04480405
commit
e4d16257b6
15
plugin.py
15
plugin.py
@ -97,6 +97,11 @@ class DDG(callbacks.Plugin):
|
|||||||
|
|
||||||
url, real_url, raw_results = self._ddgurl(text)
|
url, real_url, raw_results = self._ddgurl(text)
|
||||||
|
|
||||||
|
if real_url != url:
|
||||||
|
# We received a redirect, likely from something like a !bang request.
|
||||||
|
# Don't bother parsing the target page, as it probably won't work anyways.
|
||||||
|
return [('', '', real_url)]
|
||||||
|
|
||||||
for t in raw_results:
|
for t in raw_results:
|
||||||
res = ''
|
res = ''
|
||||||
# Each valid result has a preceding heading in the format
|
# Each valid result has a preceding heading in the format
|
||||||
@ -150,7 +155,15 @@ class DDG(callbacks.Plugin):
|
|||||||
if not results:
|
if not results:
|
||||||
irc.error("No results found.")
|
irc.error("No results found.")
|
||||||
else:
|
else:
|
||||||
strings = [format("%s - %s %u", ircutils.bold(res[0]), res[1], res[2]) for res in results]
|
strings = []
|
||||||
|
|
||||||
|
for r in results:
|
||||||
|
if not r[0]:
|
||||||
|
# This result has no title, so it's likely a redirect from !bang.
|
||||||
|
strings.append(format("See %u", r[2]))
|
||||||
|
else:
|
||||||
|
strings.append(format("%s - %s %u", ircutils.bold(r[0]), r[1], r[2]))
|
||||||
|
|
||||||
irc.reply(', '.join(strings))
|
irc.reply(', '.join(strings))
|
||||||
|
|
||||||
@wrap(['text'])
|
@wrap(['text'])
|
||||||
|
Loading…
Reference in New Issue
Block a user