wikipedia: add plus feature to "science" as well
This commit is contained in:
parent
195d0a38ea
commit
d10ef6e8b7
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue