Compare commits

...

3 commits

3 changed files with 14 additions and 0 deletions

View file

@ -149,6 +149,7 @@ class Bot(irc.client.SimpleIRCClient, Logger):
def say(self, target, message): def say(self, target, message):
"""Send message to target after a slight delay.""" """Send message to target after a slight delay."""
message = message.replace("\n", " ").replace("\r", " ")
time.sleep(self.config["speak_delay"]) time.sleep(self.config["speak_delay"])
self.log_d(f"Sending to {target}: {message}") self.log_d(f"Sending to {target}: {message}")
try: try:

View file

@ -19,16 +19,21 @@ class JourneeMondialePlugin(Plugin):
def on_pubmsg(self, event): def on_pubmsg(self, event):
if not self.should_handle_command(event.arguments[0], no_content=True): if not self.should_handle_command(event.arguments[0], no_content=True):
return False return False
response = http_get(self.config["url"]) response = http_get(self.config["url"])
if not response: if not response:
self.signal_failure(event.target) self.signal_failure(event.target)
return True return True
soup = BeautifulSoup(response, "html.parser") soup = BeautifulSoup(response, "html.parser")
try: try:
jm = soup.find("div", id="journeesDuJour").find("h2").string jm = soup.find("div", id="journeesDuJour").find("h2").string
except (ValueError, KeyError): except (ValueError, KeyError):
self.signal_failure(event.target) self.signal_failure(event.target)
return True return True
if jm: if jm:
self.bot.say(event.target, jm) self.bot.say(event.target, jm)
else:
self.signal_failure(event.target)
return True return True

View file

@ -150,6 +150,14 @@ class MiscReactionsPlugin(Plugin):
if len(words) == 0: if len(words) == 0:
return return
biggest_word = sorted(words, key=lambda w: len(w))[-1] biggest_word = sorted(words, key=lambda w: len(w))[-1]
num_repeats = 2
repeated = biggest_word[:num_repeats]
while (
(not any(letter in repeated for letter in "aeiouy"))
and len(repeated) < len(biggest_word)
):
num_repeats += 1
repeated = biggest_word[:num_repeats]
word = biggest_word[:2] + biggest_word word = biggest_word[:2] + biggest_word
question_mark = self.config["question_mark"] question_mark = self.config["question_mark"]
reply = f"{word}{question_mark}" reply = f"{word}{question_mark}"