caretaker: add plugin
This commit is contained in:
parent
bc8cf0e465
commit
cc81956b58
|
@ -53,6 +53,6 @@ Missing features
|
||||||
- [ ] Simple word mappings for fun
|
- [ ] Simple word mappings for fun
|
||||||
- ~~[ ] Lyrics~~
|
- ~~[ ] Lyrics~~
|
||||||
- [ ] Phonétique
|
- [ ] Phonétique
|
||||||
- [ ] Greet other people joining
|
- [x] Greet other people joining
|
||||||
- [ ] Mourn other people parting
|
- [x] Mourn other people parting
|
||||||
- [ ] unknown questions
|
- [ ] unknown questions
|
||||||
|
|
|
@ -14,6 +14,14 @@
|
||||||
"beers": ["Paix-Dieu"],
|
"beers": ["Paix-Dieu"],
|
||||||
"opening_text": "/me cracks open a {beer} for {target}"
|
"opening_text": "/me cracks open a {beer} for {target}"
|
||||||
},
|
},
|
||||||
|
"caretaker": {
|
||||||
|
"warm_welcome": ["Hi {target}!"],
|
||||||
|
"cold_welcome": ["Oh no..."],
|
||||||
|
"nice_farewell": [":("],
|
||||||
|
"bad_farewell": ["Good riddance."],
|
||||||
|
"welcome_rate": 10,
|
||||||
|
"farewell_rate": 10
|
||||||
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"command_suffix": "please",
|
"command_suffix": "please",
|
||||||
"handling_conditions": {
|
"handling_conditions": {
|
||||||
|
|
49
edmond/plugins/caretaker.py
Normal file
49
edmond/plugins/caretaker.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import random
|
||||||
|
|
||||||
|
from edmond.plugin import Plugin
|
||||||
|
from edmond.plugins.mood import Mood
|
||||||
|
from edmond.utils import proc
|
||||||
|
|
||||||
|
|
||||||
|
class CaretakerPlugin(Plugin):
|
||||||
|
"""Say hello and farewall on people joining/parting."""
|
||||||
|
|
||||||
|
REQUIRED_CONFIGS = [
|
||||||
|
"warm_welcome", "cold_welcome", "nice_farewell", "bad_farewell",
|
||||||
|
"welcome_rate", "farewell_rate"
|
||||||
|
]
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
super().__init__(bot)
|
||||||
|
self.mood_plugin = None
|
||||||
|
|
||||||
|
def on_welcome(self, event):
|
||||||
|
self.mood_plugin = self.bot.get_plugin("mood")
|
||||||
|
|
||||||
|
def on_join(self, event):
|
||||||
|
if event.source.nick == self.bot.nick:
|
||||||
|
return
|
||||||
|
if not proc(self.config["welcome_rate"]):
|
||||||
|
return
|
||||||
|
welcome_type = "warm_welcome"
|
||||||
|
if self.mood_plugin:
|
||||||
|
if self.get_runtime_value("mood", ns="mood") == Mood.PISSED:
|
||||||
|
welcome_type = "cold_welcome"
|
||||||
|
welcome = random.choice(self.config[welcome_type])
|
||||||
|
if "{target}" in welcome:
|
||||||
|
welcome = welcome.format(target=event.source.nick)
|
||||||
|
self.bot.say(event.target, welcome)
|
||||||
|
|
||||||
|
def on_part(self, event):
|
||||||
|
if event.source.nick == self.bot.nick:
|
||||||
|
return
|
||||||
|
if not proc(self.config["farewell_rate"]):
|
||||||
|
return
|
||||||
|
farewell_type = "nice_farewell"
|
||||||
|
if self.mood_plugin:
|
||||||
|
if self.get_runtime_value("mood", ns="mood") == Mood.PISSED:
|
||||||
|
farewell_type = "bad_farewell"
|
||||||
|
farewell = random.choice(self.config[farewell_type])
|
||||||
|
if "{target}" in farewell:
|
||||||
|
farewell = farewell.format(target=event.source.nick)
|
||||||
|
self.bot.say(event.target, farewell)
|
Loading…
Reference in a new issue