DDG: actually, return a list of tuples in search_core()

This abstraction makes it easier for depending plugins to filter out the data they actually need.

From: 4915b7713b
This commit is contained in:
James Lu 2017-01-20 18:57:55 -08:00
parent 828112eaa1
commit f5a53a1965
1 changed files with 5 additions and 3 deletions

View File

@ -127,8 +127,9 @@ class DDG(callbacks.Plugin):
else: else:
self.log.debug("DDG: expanded result URL from %s to %s", origlink, link) self.log.debug("DDG: expanded result URL from %s to %s", origlink, link)
s = format("%s - %s %u", ircutils.bold(title), snippet, link) # Return a list of tuples in the form (link title, snippet text, link)
results.append(s) results.append((title, snippet, link))
except AttributeError: except AttributeError:
continue continue
return results[:maxr] return results[:maxr]
@ -142,7 +143,8 @@ class DDG(callbacks.Plugin):
if not results: if not results:
irc.error("No results found.") irc.error("No results found.")
else: else:
irc.reply(', '.join(results)) strings = [format("%s - %s %u", ircutils.bold(res[0]), res[1], res[2]) for res in results]
irc.reply(', '.join(strings))
@wrap(['text']) @wrap(['text'])
def zeroclick(self, irc, msg, args, text): def zeroclick(self, irc, msg, args, text):