mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Make sure we keep the originally registered probability. Also, quote the
command being run like we do in an alias' help.
This commit is contained in:
parent
4a0cefc9ab
commit
9a71af37a6
@ -71,7 +71,7 @@ conf.registerChannelValue(conf.supybot.plugins.Observer.observers, 'active',
|
|||||||
|
|
||||||
|
|
||||||
def registerObserver(name, regexpString='',
|
def registerObserver(name, regexpString='',
|
||||||
commandString='', probability=1.0):
|
commandString='', probability=None):
|
||||||
g = conf.registerGlobalValue(conf.supybot.plugins.Observer.observers,
|
g = conf.registerGlobalValue(conf.supybot.plugins.Observer.observers,
|
||||||
name, registry.Regexp(regexpString, """Determines what regexp must
|
name, registry.Regexp(regexpString, """Determines what regexp must
|
||||||
match for this observer to be executed."""))
|
match for this observer to be executed."""))
|
||||||
@ -82,8 +82,9 @@ def registerObserver(name, regexpString='',
|
|||||||
if commandString:
|
if commandString:
|
||||||
g.command.setValue(commandString)
|
g.command.setValue(commandString)
|
||||||
conf.registerGlobalValue(g, 'probability',
|
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."""))
|
of executing this observer is if it matches."""))
|
||||||
|
if probability is not None:
|
||||||
g.probability.setValue(probability)
|
g.probability.setValue(probability)
|
||||||
conf.supybot.plugins.Observer.observers().add(name)
|
conf.supybot.plugins.Observer.observers().add(name)
|
||||||
return g
|
return g
|
||||||
@ -190,7 +191,7 @@ class Observer(callbacks.Privmsg):
|
|||||||
command = g.command()
|
command = g.command()
|
||||||
probability = g.probability()
|
probability = g.probability()
|
||||||
irc.reply('%s matches the regular expression %s and '
|
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))
|
(name, g, command, probability))
|
||||||
info = wrap(info, ['something'])
|
info = wrap(info, ['something'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user