Add support for commands in multiple words by letting a plugin decide if the message content should be not split between ident/content.master
parent
828802fdbe
commit
f4e884e9d7
@ -0,0 +1,33 @@
|
|||||||
|
try:
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
DEPENDENCIES_FOUND = True
|
||||||
|
except ImportError:
|
||||||
|
DEPENDENCIES_FOUND = False
|
||||||
|
|
||||||
|
from edmond.plugin import Plugin
|
||||||
|
from edmond.utils import http_get
|
||||||
|
|
||||||
|
|
||||||
|
class JourneeMondialePlugin(Plugin):
|
||||||
|
"""This plugin gets today's international observance (french)."""
|
||||||
|
|
||||||
|
REQUIRED_CONFIGS = ["commands", "url"]
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
super().__init__(bot)
|
||||||
|
|
||||||
|
def on_pubmsg(self, event):
|
||||||
|
if not self.should_handle_command(event.arguments[0], no_content=True):
|
||||||
|
return False
|
||||||
|
response = http_get(self.config["url"])
|
||||||
|
if not response:
|
||||||
|
self.signal_failure()
|
||||||
|
return True
|
||||||
|
soup = BeautifulSoup(response, "html.parser")
|
||||||
|
try:
|
||||||
|
jm = soup.find("div", id="journeesDuJour").find("h2").string
|
||||||
|
except (ValueError, KeyError):
|
||||||
|
self.signal_failure()
|
||||||
|
return True
|
||||||
|
self.bot.say(event.target, jm)
|
||||||
|
return True
|
@ -0,0 +1,5 @@
|
|||||||
|
# Wikipedia
|
||||||
|
wikipedia
|
||||||
|
|
||||||
|
# Journée Mondiale
|
||||||
|
beautifulsoup4
|
Loading…
Reference in new issue