From d10ef6e8b727fe564024763047111c32e50ee7ae Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 2 Sep 2022 10:51:40 +0200 Subject: [PATCH] wikipedia: add plus feature to "science" as well --- edmond/plugins/wikipedia.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/edmond/plugins/wikipedia.py b/edmond/plugins/wikipedia.py index c8e8154..5d46427 100644 --- a/edmond/plugins/wikipedia.py +++ b/edmond/plugins/wikipedia.py @@ -42,13 +42,17 @@ class WikipediaPlugin(Plugin): retries = self.NUM_RETRIES while retries > 0: try: - summary = wikipedia.summary(wikipedia.random(), sentences=1) + page = wikipedia.page(title=wikipedia.random(), sentences=1) break except: # The wikipedia package can raise a lot of different stuff. pass retries -= 1 - if summary: - self.bot.say(event.target, summary) + if page: + if plus_plugin := self.bot.get_plugin("plus"): + def handler(plus_event): + self.bot.say(plus_event.target, page.url) + plus_plugin.add_handler(event.target, handler) + self.bot.say(event.target, page.summary) def tell_definition(self, event): page = None