sleep: allow multiple sleep/wakeup messages
This commit is contained in:
parent
4480a3b44a
commit
29258a13b4
|
@ -62,8 +62,8 @@
|
|||
"sleep_time": 23,
|
||||
"wakeup_time": 7,
|
||||
"snore": "Zzzz",
|
||||
"sleep_message": "/me falls asleep",
|
||||
"wakeup_message": "/me wakes up",
|
||||
"sleep_messages": ["/me falls asleep"],
|
||||
"wakeup_messages": ["/me wakes up"],
|
||||
"snore_rate": 1.0
|
||||
},
|
||||
"wikipedia": {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import random
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from edmond.plugin import Plugin
|
||||
|
@ -8,8 +9,8 @@ class SleepPlugin(Plugin):
|
|||
"""Handle sleep state of the bot, snore a little bit."""
|
||||
|
||||
REQUIRED_CONFIGS = [
|
||||
"commands", "sleep_time", "wakeup_time", "snore", "sleep_message",
|
||||
"wakeup_message", "snore_rate"
|
||||
"commands", "sleep_time", "wakeup_time", "snore", "sleep_messages",
|
||||
"wakeup_messages", "snore_rate"
|
||||
]
|
||||
|
||||
def __init__(self, bot):
|
||||
|
@ -58,7 +59,7 @@ class SleepPlugin(Plugin):
|
|||
if not self.get_runtime_value("awake"):
|
||||
return
|
||||
for channel in self.bot.channels:
|
||||
self.bot.say(channel, self.config["sleep_message"])
|
||||
self.bot.say(channel, random.choice(self.config["sleep_messages"]))
|
||||
self.set_runtime_value("awake", False)
|
||||
|
||||
def wake_up(self):
|
||||
|
@ -66,7 +67,7 @@ class SleepPlugin(Plugin):
|
|||
return
|
||||
self.set_runtime_value("awake", True)
|
||||
for channel in self.bot.channels:
|
||||
self.bot.say(channel, self.config["wakeup_message"])
|
||||
self.bot.say(channel, random.choice(self.config["wakeup_messages"]))
|
||||
|
||||
def is_sleep_time(self, now):
|
||||
"""Return True if the bot should be sleeping by now.
|
||||
|
|
Loading…
Reference in a new issue