diff --git a/plugins/Anonymous.py b/plugins/Anonymous.py index 90219b4b3..e649a371a 100644 --- a/plugins/Anonymous.py +++ b/plugins/Anonymous.py @@ -38,8 +38,8 @@ import supybot.plugins as plugins import supybot.conf as conf import supybot.utils as utils import supybot.ircdb as ircdb +from supybot.commands import * import supybot.ircmsgs as ircmsgs -import supybot.privmsgs as privmsgs import supybot.registry as registry import supybot.callbacks as callbacks @@ -78,9 +78,6 @@ class Anonymous(callbacks.Privmsg): _ = ircdb.users.getUser(msg.prefix) except KeyError: irc.errorNotRegistered(Raise=True) - if channel not in irc.state.channels: - irc.error('I\'m not in %s, chances are that I can\'t say anything ' - 'in there.' % channel, Raise=True) capability = self.registryValue('requireCapability') if capability: if not ircdb.checkCapability(msg.prefix, capability): @@ -96,27 +93,27 @@ class Anonymous(callbacks.Privmsg): irc.error('That channel has set its capabilities so as to ' 'disallow the use of this plugin.', Raise=True) - def say(self, irc, msg, args): + def say(self, irc, msg, args, channel, text): """ Sends to . """ - (channel, text) = privmsgs.getArgs(args, required=2) self._preCheck(irc, msg, channel) self.log.info('Saying %s in %s due to %s.', utils.quoted(text), channel, msg.prefix) irc.queueMsg(ircmsgs.privmsg(channel, text)) + say = wrap(say, ['inChannel', 'text']) - def do(self, irc, msg, args): + def do(self, irc, msg, args, channel, text): """ Performs in . """ - (channel, action) = privmsgs.getArgs(args, required=2) self._preCheck(irc, msg, channel) self.log.info('Performing %s in %s due to %s.', - utils.quoted(action), channel, msg.prefix) - irc.queueMsg(ircmsgs.action(channel, action)) + utils.quoted(text), channel, msg.prefix) + irc.queueMsg(ircmsgs.action(channel, text)) + do = wrap(do, ['inChannel', 'text']) Class = Anonymous diff --git a/plugins/Observer.py b/plugins/Observer.py index d85474171..8f22479bc 100644 --- a/plugins/Observer.py +++ b/plugins/Observer.py @@ -41,7 +41,7 @@ import random import supybot.conf as conf import supybot.utils as utils -import supybot.privmsgs as privmsgs +from supybot.commands import * import supybot.registry as registry import supybot.callbacks as callbacks @@ -165,39 +165,36 @@ class Observer(callbacks.Privmsg): else: irc.reply('There were no relevant observers.') - def enable(self, irc, msg, args, channel): + def enable(self, irc, msg, args, channel, name): """[] Enables the observer in . is only necessary if the message isn't sent in the channel itself. """ - name = privmsgs.getArgs(args) if name not in self.registryValue('observers'): irc.error('There is no observer %s.' % name, Raise=True) self.registryValue('observers.active', channel).append(name) irc.replySuccess() - enable = privmsgs.checkChannelCapability(enable, 'op') + enable = wrap(enable, [('checkChannelCapability', 'op'), 'something']) - def disable(self, irc, msg, args, channel): + def disable(self, irc, msg, args, channel, name): """[] Disables the observer in . is only necessary if the message isn't sent in the channel itself. """ - name = privmsgs.getArgs(args) try: self.registryValue('observers.active', channel).remove(name) irc.replySuccess() except (KeyError, ValueError): irc.error('The observer %s was not active on %s.' % (name,channel)) - disable = privmsgs.checkChannelCapability(disable, 'op') + disable = wrap(disable, [('checkChannelCapability', 'op'), 'something']) - def info(self, irc, msg, args): + def info(self, irc, msg, args, name): """ Returns the relevant information on the observer specified by . """ - name = privmsgs.getArgs(args) if name not in self.registryValue('observers'): irc.error('That\'s not a valid observer.', Raise=True) g = self.registryValue('observers.%s' % name, value=False) @@ -207,8 +204,9 @@ class Observer(callbacks.Privmsg): irc.reply('%s matches the regular expression %s and ' 'runs the command %s with a probability of %s' % (name, regexp, command, probability)) + info = wrap(info, ['something']) - def add(self, irc, msg, args): + def add(self, irc, msg, args, name, probability, regexp, command): """ [] Calls when matches a given message. Before @@ -218,19 +216,15 @@ class Observer(callbacks.Privmsg): otherwise it should be a floating point probability that the observer will execute if it matches. """ - if len(args) < 3: - raise callbacks.ArgumentError - try: - probability = float(args[1]) - del args[1] - except ValueError: - probability = 1.0 - (name, regexp, command) = privmsgs.getArgs(args, required=3) if not registry.isValidRegistryName(name): irc.error('That\'s not a valid observer name. Please be sure ' 'there are no spaces in the name.', Raise=True) registerObserver(name, regexp, command, probability) irc.replySuccess() + add = wrap(add, ['something', + optional('float', 1.0), + ('regexpMatcher', False), + 'text']) def remove(self, irc, msg, args): """