From 9a71af37a66325126ac45eab836a94d3cbdf6faf Mon Sep 17 00:00:00 2001 From: James Vega Date: Sun, 28 Nov 2004 09:03:39 +0000 Subject: [PATCH] Make sure we keep the originally registered probability. Also, quote the command being run like we do in an alias' help. --- plugins/Observer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/Observer.py b/plugins/Observer.py index c1818d69d..85dda3691 100644 --- a/plugins/Observer.py +++ b/plugins/Observer.py @@ -71,7 +71,7 @@ conf.registerChannelValue(conf.supybot.plugins.Observer.observers, 'active', def registerObserver(name, regexpString='', - commandString='', probability=1.0): + commandString='', probability=None): g = conf.registerGlobalValue(conf.supybot.plugins.Observer.observers, name, registry.Regexp(regexpString, """Determines what regexp must match for this observer to be executed.""")) @@ -82,9 +82,10 @@ def registerObserver(name, regexpString='', if commandString: g.command.setValue(commandString) conf.registerGlobalValue(g, 'probability', - registry.Probability(probability, """ Determines what the probability + registry.Probability(1.0, """ Determines what the probability of executing this observer is if it matches.""")) - g.probability.setValue(probability) + if probability is not None: + g.probability.setValue(probability) conf.supybot.plugins.Observer.observers().add(name) return g @@ -190,7 +191,7 @@ class Observer(callbacks.Privmsg): command = g.command() probability = g.probability() irc.reply('%s matches the regular expression %s and ' - 'runs the command %s with a probability of %s' % + 'runs the command <<%s>> with a probability of %s' % (name, g, command, probability)) info = wrap(info, ['something'])