[mediawiki] fix OpenSearch: can have empty description
This commit is contained in:
parent
7a1ad6430c
commit
bbf5acafbb
1 changed files with 11 additions and 9 deletions
|
@ -70,7 +70,7 @@ def opensearch(site, term, ssl=False):
|
||||||
if response is not None and response.hasNode("Section"):
|
if response is not None and response.hasNode("Section"):
|
||||||
for itm in response.getNode("Section").getNodes("Item"):
|
for itm in response.getNode("Section").getNodes("Item"):
|
||||||
yield (itm.getNode("Text").getContent(),
|
yield (itm.getNode("Text").getContent(),
|
||||||
itm.getNode("Description").getContent(),
|
itm.getNode("Description").getContent() if itm.hasNode("Description") else "",
|
||||||
itm.getNode("Url").getContent())
|
itm.getNode("Url").getContent())
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,14 +163,16 @@ def mediawiki_response(site, term, receivers):
|
||||||
line_treat=lambda line: irc_format(parse_wikitext(site, line, ns)),
|
line_treat=lambda line: irc_format(parse_wikitext(site, line, ns)),
|
||||||
channel=receivers)
|
channel=receivers)
|
||||||
except:
|
except:
|
||||||
# Try looking at opensearch
|
pass
|
||||||
os = [x for x, _, _ in opensearch(site, terms[0])]
|
|
||||||
# Fallback to global search
|
# Try looking at opensearch
|
||||||
if not len(os):
|
os = [x for x, _, _ in opensearch(site, terms[0])]
|
||||||
os = [x for x, _ in search(site, terms[0]) if x is not None and x != ""]
|
# Fallback to global search
|
||||||
return Response(os,
|
if not len(os):
|
||||||
channel=receivers,
|
os = [x for x, _ in search(site, terms[0]) if x is not None and x != ""]
|
||||||
title="Article not found, would you mean")
|
return Response(os,
|
||||||
|
channel=receivers,
|
||||||
|
title="Article not found, would you mean")
|
||||||
|
|
||||||
|
|
||||||
@hook("cmd_hook", "mediawiki")
|
@hook("cmd_hook", "mediawiki")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue