yell: new plugin
This commit is contained in:
parent
a7d3a18ea7
commit
ae98235433
|
@ -200,6 +200,11 @@
|
|||
"ambiguous_response": "It is ambiguous.",
|
||||
"empty_response": "I can't find it."
|
||||
},
|
||||
"yell": {
|
||||
"commands": ["yell"],
|
||||
"target_word": "to",
|
||||
"loudness": 5
|
||||
},
|
||||
"youtube": {
|
||||
"commands": ["youtube"],
|
||||
"api_key": ""
|
||||
|
|
33
edmond/plugins/yell.py
Normal file
33
edmond/plugins/yell.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
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()
|
Loading…
Reference in a new issue