Compare commits
3 commits
5f4af12a2f
...
1e9f10d549
Author | SHA1 | Date | |
---|---|---|---|
dece | 1e9f10d549 | ||
dece | 6b9430aabb | ||
dece | 56656dca98 |
|
@ -149,6 +149,7 @@ class Bot(irc.client.SimpleIRCClient, Logger):
|
|||
|
||||
def say(self, target, message):
|
||||
"""Send message to target after a slight delay."""
|
||||
message = message.replace("\n", " ").replace("\r", " ")
|
||||
time.sleep(self.config["speak_delay"])
|
||||
self.log_d(f"Sending to {target}: {message}")
|
||||
try:
|
||||
|
|
|
@ -19,16 +19,21 @@ class JourneeMondialePlugin(Plugin):
|
|||
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(event.target)
|
||||
return True
|
||||
|
||||
soup = BeautifulSoup(response, "html.parser")
|
||||
try:
|
||||
jm = soup.find("div", id="journeesDuJour").find("h2").string
|
||||
except (ValueError, KeyError):
|
||||
self.signal_failure(event.target)
|
||||
return True
|
||||
|
||||
if jm:
|
||||
self.bot.say(event.target, jm)
|
||||
else:
|
||||
self.signal_failure(event.target)
|
||||
return True
|
||||
|
|
|
@ -150,6 +150,14 @@ class MiscReactionsPlugin(Plugin):
|
|||
if len(words) == 0:
|
||||
return
|
||||
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
|
||||
question_mark = self.config["question_mark"]
|
||||
reply = f"{word}{question_mark}"
|
||||
|
|
Loading…
Reference in a new issue