taxref: tell family name as well

This commit is contained in:
dece 2022-07-07 19:07:50 +02:00
parent 8020de4edf
commit 659dae9ce6

View file

@ -150,17 +150,27 @@ class TaxrefPlugin(Plugin):
if len(items) == 1:
# Only one result: use it.
reply = items[0].get("scientificName")
reply = TaxrefPlugin.item_to_full_name(items[0])
else:
# More than one result? For simplicity sake, use the shrlok plugin
# if available or just show an ambiguous response.
if (shrlok := self.bot.get_plugin("shrlok")):
text = "\n".join(
f"{i['frenchVernacularName']}{i['scientificName']}"
for i in items
(
item['frenchVernacularName'] +
"" +
TaxrefPlugin.item_to_full_name(item)
)
for item in items
) + "\n"
reply = shrlok.post_text(text)
else:
reply = self.get_ambiguous_reply(items)
self.bot.say(target, reply)
@staticmethod
def item_to_full_name(item):
family_name = item.get("familyName")
sci_name = item.get("scientificName")
return f"{family_name} {sci_name}"