You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
966 B

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