34 lines
990 B
Python
34 lines
990 B
Python
|
import random
|
||
|
|
||
|
from edmond.plugin import Plugin
|
||
|
|
||
|
|
||
|
class YellPlugin(Plugin):
|
||
|
|
||
|
REQUIRED_CONFIGS = ["commands", "target_word", "loudness"]
|
||
|
|
||
|
def __init__(self, bot):
|
||
|
super().__init__(bot)
|
||
|
|
||
|
def on_pubmsg(self, event):
|
||
|
if not self.should_handle_command(event.arguments[0]):
|
||
|
return False
|
||
|
words = self.command.content.split()
|
||
|
if len(words) >= 3 and words[-2] == self.config["target_word"]:
|
||
|
del words[-2]
|
||
|
self.bot.say(event.target, self.amplify(words))
|
||
|
return True
|
||
|
|
||
|
def amplify(self, words: list[str]) -> str:
|
||
|
loud_words = []
|
||
|
loudness = self.config["loudness"]
|
||
|
for word in words:
|
||
|
loud_word = ""
|
||
|
for char in word:
|
||
|
if char in "aeiouy":
|
||
|
loud_word += char * random.randint(1, loudness)
|
||
|
else:
|
||
|
loud_word += char
|
||
|
loud_words.append(loud_word)
|
||
|
return " ".join(loud_words).upper()
|