diff --git a/plugins/Dunno.py b/plugins/Dunno.py index f7ee00aa5..46d6f835f 100644 --- a/plugins/Dunno.py +++ b/plugins/Dunno.py @@ -104,7 +104,7 @@ class Dunno(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return text = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() @@ -123,7 +123,7 @@ class Dunno(callbacks.Privmsg): try: user_id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return dunno_id = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() diff --git a/plugins/Factoids.py b/plugins/Factoids.py index b1605b4b6..1aa146972 100644 --- a/plugins/Factoids.py +++ b/plugins/Factoids.py @@ -107,14 +107,15 @@ class Factoids(plugins.ChannelDBHandler, db.commit() return db - def learn(self, irc, msg, args, channel): + def learn(self, irc, msg, args): """[] as Associates with . is only necessary if the - message isn't sent on the channel itself. The word "as" is necessary + message isn't sent on the channel itself. The word 'as' is necessary to separate the key from the value. It can be changed to another word via the learn-separator configurable. """ + channel = privmsgs.getChannel(msg, args) try: separator = self.configurables.get('learn-separator', channel) i = args.index(separator) @@ -189,13 +190,14 @@ class Factoids(plugins.ChannelDBHandler, irc.error('That\'s not a valid number for this key.') return - def lock(self, irc, msg, args, channel): + def lock(self, irc, msg, args): """[] Locks the factoid(s) associated with so that they cannot be removed or added to. is only necessary if the message isn't sent in the channel itself. """ + channel = privmsgs.getChannel(msg, args) key = privmsgs.getArgs(args) db = self.getDb(channel) cursor = db.cursor() @@ -203,13 +205,14 @@ class Factoids(plugins.ChannelDBHandler, db.commit() irc.replySuccess() - def unlock(self, irc, msg, args, channel): + def unlock(self, irc, msg, args): """[] Unlocks the factoid(s) associated with so that they can be removed or added to. is only necessary if the message isn't sent in the channel itself. """ + channel = privmsgs.getChannel(msg, args) key = privmsgs.getArgs(args) db = self.getDb(channel) cursor = db.cursor() @@ -217,7 +220,7 @@ class Factoids(plugins.ChannelDBHandler, db.commit() irc.replySuccess() - def forget(self, irc, msg, args, channel): + def forget(self, irc, msg, args): """[] [|*] Removes the factoid from the factoids database. If there are @@ -226,6 +229,7 @@ class Factoids(plugins.ChannelDBHandler, factoids associated with a key. is only necessary if the message isn't sent in the channel itself. """ + channel = privmsgs.getChannel(msg, args) if args[-1].isdigit(): number = int(args.pop()) number -= 1 @@ -324,12 +328,13 @@ class Factoids(plugins.ChannelDBHandler, utils.nItems('factoid', counter), factoids) irc.reply(s) - def change(self, irc, msg, args, channel): + def change(self, irc, msg, args): """[] Changes the factoid # associated with according to . """ + channel = privmsgs.getChannel(msg, args) (key, number, regexp) = privmsgs.getArgs(args, required=3) try: replacer = utils.perlReToReplacer(regexp) diff --git a/plugins/FunDB.py b/plugins/FunDB.py index 3509c48a1..005eddcbb 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -138,7 +138,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler): try: name = ircdb.users.getUser(msg.prefix).name except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return if table == "lart" or table == "praise": if '$who' not in s: @@ -173,7 +173,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler): try: ircdb.users.getUser(msg.prefix).name except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return try: id = int(id) @@ -206,7 +206,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler): try: name = ircdb.users.getUser(msg.prefix).name except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return try: id = int(id) diff --git a/plugins/MoobotFactoids.py b/plugins/MoobotFactoids.py index efc7dca9f..fe2360f67 100644 --- a/plugins/MoobotFactoids.py +++ b/plugins/MoobotFactoids.py @@ -251,7 +251,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return key, fact = match.groups() # These are okay, unless there's an _is_ in there, in which case @@ -279,7 +279,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return key, regexp = match.groups() db = self.dbHandler.getDb() @@ -315,7 +315,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return key, new_text = match.groups() db = self.dbHandler.getDb() @@ -346,7 +346,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return key, new_fact = match.groups() # These are okay, unless there's an _is_ in there, in which case @@ -450,7 +450,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return key = privmsgs.getArgs(args, required=1) db = self.dbHandler.getDb() @@ -640,7 +640,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): try: ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return key = privmsgs.getArgs(args, required=1) db = self.dbHandler.getDb() diff --git a/plugins/Note.py b/plugins/Note.py index 32baadd8b..7fa002ec0 100644 --- a/plugins/Note.py +++ b/plugins/Note.py @@ -139,7 +139,7 @@ class Note(callbacks.Privmsg): try: fromId = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return if ircutils.isChannel(msg.args[0]): public = 1 @@ -168,7 +168,7 @@ class Note(callbacks.Privmsg): try: userid = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return db = self.dbHandler.getDb() cursor = db.cursor() @@ -197,7 +197,7 @@ class Note(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return try: noteid = int(noteid) @@ -247,7 +247,7 @@ class Note(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return db = self.dbHandler.getDb() cursor = db.cursor() @@ -270,7 +270,7 @@ class Note(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return db = self.dbHandler.getDb() cursor = db.cursor() diff --git a/plugins/Poll.py b/plugins/Poll.py index c28b8b74c..602d7d1c5 100644 --- a/plugins/Poll.py +++ b/plugins/Poll.py @@ -138,7 +138,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler): try: userId = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return db = self.getDb(channel) cursor = db.cursor() @@ -187,7 +187,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler): try: userId = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return db = self.getDb(channel) cursor = db.cursor() @@ -237,7 +237,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler): try: userId = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return db = self.getDb(channel) cursor = db.cursor() diff --git a/plugins/Todo.py b/plugins/Todo.py index b58d2d3c2..18afe83f7 100644 --- a/plugins/Todo.py +++ b/plugins/Todo.py @@ -125,7 +125,7 @@ class Todo(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return cursor.execute("""SELECT id, task FROM todo WHERE userid = %s AND active = 1 @@ -186,7 +186,7 @@ class Todo(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return (optlist, rest) = getopt.getopt(args, '', ['priority=']) priority = 0 @@ -218,7 +218,7 @@ class Todo(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return taskids = privmsgs.getArgs(args) tasks = taskids.split() @@ -256,7 +256,7 @@ class Todo(callbacks.Privmsg): try: id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return (optlist, rest) = getopt.getopt(args, '', ['regexp=']) if not optlist and not rest: @@ -301,7 +301,7 @@ class Todo(callbacks.Privmsg): try: user_id = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return (id, priority) = privmsgs.getArgs(args, required=2) db = self.dbHandler.getDb() @@ -329,7 +329,7 @@ class Todo(callbacks.Privmsg): try: userid = ircdb.users.getUserId(msg.prefix) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return taskid, regexp = privmsgs.getArgs(args, required=2) # Check the regexp first, it's easier and doesn't require a db query diff --git a/src/User.py b/src/User.py index f38fa464f..2c6995365 100755 --- a/src/User.py +++ b/src/User.py @@ -303,7 +303,7 @@ class User(callbacks.Privmsg): else: irc.reply(repr(user.hostmasks)) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() def capabilities(self, irc, msg, args): """[] @@ -371,7 +371,7 @@ class User(callbacks.Privmsg): user = ircdb.users.getUser(msg.prefix) irc.reply(user.name) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() def setsecure(self, irc, msg, args): """ [] @@ -389,7 +389,7 @@ class User(callbacks.Privmsg): id = ircdb.users.getUserId(msg.prefix) user = ircdb.users.getUser(id) except KeyError: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() if value == '': value = not user.secure elif value.lower() in ('true', 'false'): diff --git a/src/callbacks.py b/src/callbacks.py index 8cc060909..35024f4a2 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -271,7 +271,7 @@ def formatArgumentError(method, name=None): else: return 'Invalid arguments for %s.' % method.__name__ -def checkCommandCapability(msg, command): +def checkCommandCapability(msg, cb, command): anticap = ircdb.makeAntiCapability(command) if ircdb.checkCapability(msg.prefix, anticap): log.info('Preventing because of anticap: %s', msg.prefix) @@ -409,8 +409,8 @@ class IrcObjectProxy(RichReplyMethods): else: del self.args[0] cb = cbs[0] - if not checkCommandCapability(self.msg, name): - self.error(conf.replyNoCapability % name) + if not checkCommandCapability(self.msg, cb, name): + self.errorNoCapability(name) return command = getattr(cb, name) Privmsg.handled = True @@ -636,8 +636,8 @@ class Privmsg(irclib.IrcCallback): if name == canonicalName(self.name()): handleBadArgs() elif self.isCommand(name): - if not checkCommandCapability(msg, name): - irc.error(conf.replyNoCapability % name) + if not checkCommandCapability(msg, self, name): + irc.errorNoCapability(name) return del args[0] method = getattr(self, name) diff --git a/src/privmsgs.py b/src/privmsgs.py index 380c68c59..0ac32de86 100644 --- a/src/privmsgs.py +++ b/src/privmsgs.py @@ -143,7 +143,7 @@ def name(f): name = ircdb.users.getUser(msg.prefix).name except KeyError: if conf.requireRegistration: - irc.error(conf.replyNotRegistered) + irc.errorNotRegistered() return else: name = msg.prefix