wikipedia: add plus feature to "science" as well

This commit is contained in:
dece 2022-09-02 10:51:40 +02:00
parent 195d0a38ea
commit d10ef6e8b7

View file

@ -42,13 +42,17 @@ class WikipediaPlugin(Plugin):
retries = self.NUM_RETRIES retries = self.NUM_RETRIES
while retries > 0: while retries > 0:
try: try:
summary = wikipedia.summary(wikipedia.random(), sentences=1) page = wikipedia.page(title=wikipedia.random(), sentences=1)
break break
except: # The wikipedia package can raise a lot of different stuff. except: # The wikipedia package can raise a lot of different stuff.
pass pass
retries -= 1 retries -= 1
if summary: if page:
self.bot.say(event.target, summary) 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): def tell_definition(self, event):
page = None page = None