From 190d42fbb527a8710a8e710dc3260ad8054a9d1d Mon Sep 17 00:00:00 2001 From: Evelyn Date: Sun, 10 Apr 2016 17:40:58 +0100 Subject: simpler boolean channel settings --- modules/auto_mode.py | 6 ++---- modules/karma.py | 5 ++--- modules/sed.py | 5 ++--- modules/youtube.py | 4 +--- 4 files changed, 7 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/auto_mode.py b/modules/auto_mode.py index b369bcbd..2d7370a4 100644 --- a/modules/auto_mode.py +++ b/modules/auto_mode.py @@ -1,4 +1,4 @@ - +import Utils class Module(object): def __init__(self, bot): @@ -7,13 +7,11 @@ class Module(object): bot.events.on("channel").on("mode").hook(self.on_mode) bot.events.on("received").on("join").hook(self.on_join) - def validate_setchannel(self, s): - return s.lower() == "true" def boot_done(self, event): self.bot.events.on("postboot").on("configure").on( "channelset").call(setting="automode", help="Disable/Enable automode", - validate=self.validate_setchannel) + validate=Utils.bool_or_none) def on_mode(self, event): if event["channel"].get_setting("automode", False): diff --git a/modules/karma.py b/modules/karma.py index e51d018f..b36ca18e 100644 --- a/modules/karma.py +++ b/modules/karma.py @@ -1,4 +1,5 @@ import re, time +import Utils REGEX_KARMA = re.compile("(.*)(\+{2,}|\-{2,})") KARMA_DELAY_SECONDS = 3 @@ -14,13 +15,11 @@ class Module(object): usage="[target]") bot.events.on("boot").on("done").hook(self.boot_done) - def validate_setchannel(self, s): - return s.lower() == "true" def boot_done(self, event): self.bot.events.on("postboot").on("configure").on( "channelset").call(setting="karmaverbose", help="Disable/Enable automatically responding to karma changes", - validate=self.validate_setchannel) + validate=Utils.bool_or_none) def new_user(self, event): event["user"].last_karma = None diff --git a/modules/sed.py b/modules/sed.py index 6bdd1cb0..01bbdf4c 100644 --- a/modules/sed.py +++ b/modules/sed.py @@ -1,4 +1,5 @@ import re, traceback +import Utils REGEX_SPLIT = re.compile("(?