Updated replyNotRegistered stuff.

This commit is contained in:
Jeremy Fincher 2004-01-08 21:49:10 +00:00
parent 2846b4ab2f
commit 845142e688
10 changed files with 45 additions and 40 deletions

View File

@ -104,7 +104,7 @@ class Dunno(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
text = privmsgs.getArgs(args, required=1) text = privmsgs.getArgs(args, required=1)
cursor = self.db.cursor() cursor = self.db.cursor()
@ -123,7 +123,7 @@ class Dunno(callbacks.Privmsg):
try: try:
user_id = ircdb.users.getUserId(msg.prefix) user_id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
dunno_id = privmsgs.getArgs(args, required=1) dunno_id = privmsgs.getArgs(args, required=1)
cursor = self.db.cursor() cursor = self.db.cursor()

View File

@ -107,14 +107,15 @@ class Factoids(plugins.ChannelDBHandler,
db.commit() db.commit()
return db return db
def learn(self, irc, msg, args, channel): def learn(self, irc, msg, args):
"""[<channel>] <key> as <value> """[<channel>] <key> as <value>
Associates <key> with <value>. <channel> is only necessary if the Associates <key> with <value>. <channel> 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 to separate the key from the value. It can be changed to another
word via the learn-separator configurable. word via the learn-separator configurable.
""" """
channel = privmsgs.getChannel(msg, args)
try: try:
separator = self.configurables.get('learn-separator', channel) separator = self.configurables.get('learn-separator', channel)
i = args.index(separator) i = args.index(separator)
@ -189,13 +190,14 @@ class Factoids(plugins.ChannelDBHandler,
irc.error('That\'s not a valid number for this key.') irc.error('That\'s not a valid number for this key.')
return return
def lock(self, irc, msg, args, channel): def lock(self, irc, msg, args):
"""[<channel>] <key> """[<channel>] <key>
Locks the factoid(s) associated with <key> so that they cannot be Locks the factoid(s) associated with <key> so that they cannot be
removed or added to. <channel> is only necessary if the message isn't removed or added to. <channel> is only necessary if the message isn't
sent in the channel itself. sent in the channel itself.
""" """
channel = privmsgs.getChannel(msg, args)
key = privmsgs.getArgs(args) key = privmsgs.getArgs(args)
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()
@ -203,13 +205,14 @@ class Factoids(plugins.ChannelDBHandler,
db.commit() db.commit()
irc.replySuccess() irc.replySuccess()
def unlock(self, irc, msg, args, channel): def unlock(self, irc, msg, args):
"""[<channel>] <key> """[<channel>] <key>
Unlocks the factoid(s) associated with <key> so that they can be Unlocks the factoid(s) associated with <key> so that they can be
removed or added to. <channel> is only necessary if the message isn't removed or added to. <channel> is only necessary if the message isn't
sent in the channel itself. sent in the channel itself.
""" """
channel = privmsgs.getChannel(msg, args)
key = privmsgs.getArgs(args) key = privmsgs.getArgs(args)
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()
@ -217,7 +220,7 @@ class Factoids(plugins.ChannelDBHandler,
db.commit() db.commit()
irc.replySuccess() irc.replySuccess()
def forget(self, irc, msg, args, channel): def forget(self, irc, msg, args):
"""[<channel>] <key> [<number>|*] """[<channel>] <key> [<number>|*]
Removes the factoid <key> from the factoids database. If there are Removes the factoid <key> from the factoids database. If there are
@ -226,6 +229,7 @@ class Factoids(plugins.ChannelDBHandler,
factoids associated with a key. <channel> is only necessary if factoids associated with a key. <channel> is only necessary if
the message isn't sent in the channel itself. the message isn't sent in the channel itself.
""" """
channel = privmsgs.getChannel(msg, args)
if args[-1].isdigit(): if args[-1].isdigit():
number = int(args.pop()) number = int(args.pop())
number -= 1 number -= 1
@ -324,12 +328,13 @@ class Factoids(plugins.ChannelDBHandler,
utils.nItems('factoid', counter), factoids) utils.nItems('factoid', counter), factoids)
irc.reply(s) irc.reply(s)
def change(self, irc, msg, args, channel): def change(self, irc, msg, args):
"""[<channel>] <key> <number> <regexp> """[<channel>] <key> <number> <regexp>
Changes the factoid #<number> associated with <key> according to Changes the factoid #<number> associated with <key> according to
<regexp>. <regexp>.
""" """
channel = privmsgs.getChannel(msg, args)
(key, number, regexp) = privmsgs.getArgs(args, required=3) (key, number, regexp) = privmsgs.getArgs(args, required=3)
try: try:
replacer = utils.perlReToReplacer(regexp) replacer = utils.perlReToReplacer(regexp)

View File

@ -138,7 +138,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler):
try: try:
name = ircdb.users.getUser(msg.prefix).name name = ircdb.users.getUser(msg.prefix).name
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
if table == "lart" or table == "praise": if table == "lart" or table == "praise":
if '$who' not in s: if '$who' not in s:
@ -173,7 +173,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler):
try: try:
ircdb.users.getUser(msg.prefix).name ircdb.users.getUser(msg.prefix).name
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
try: try:
id = int(id) id = int(id)
@ -206,7 +206,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler):
try: try:
name = ircdb.users.getUser(msg.prefix).name name = ircdb.users.getUser(msg.prefix).name
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
try: try:
id = int(id) id = int(id)

View File

@ -251,7 +251,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
key, fact = match.groups() key, fact = match.groups()
# These are okay, unless there's an _is_ in there, in which case # These are okay, unless there's an _is_ in there, in which case
@ -279,7 +279,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
key, regexp = match.groups() key, regexp = match.groups()
db = self.dbHandler.getDb() db = self.dbHandler.getDb()
@ -315,7 +315,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
key, new_text = match.groups() key, new_text = match.groups()
db = self.dbHandler.getDb() db = self.dbHandler.getDb()
@ -346,7 +346,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
key, new_fact = match.groups() key, new_fact = match.groups()
# These are okay, unless there's an _is_ in there, in which case # These are okay, unless there's an _is_ in there, in which case
@ -450,7 +450,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
key = privmsgs.getArgs(args, required=1) key = privmsgs.getArgs(args, required=1)
db = self.dbHandler.getDb() db = self.dbHandler.getDb()
@ -640,7 +640,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
try: try:
ircdb.users.getUserId(msg.prefix) ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
key = privmsgs.getArgs(args, required=1) key = privmsgs.getArgs(args, required=1)
db = self.dbHandler.getDb() db = self.dbHandler.getDb()

View File

@ -139,7 +139,7 @@ class Note(callbacks.Privmsg):
try: try:
fromId = ircdb.users.getUserId(msg.prefix) fromId = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
if ircutils.isChannel(msg.args[0]): if ircutils.isChannel(msg.args[0]):
public = 1 public = 1
@ -168,7 +168,7 @@ class Note(callbacks.Privmsg):
try: try:
userid = ircdb.users.getUserId(msg.prefix) userid = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
db = self.dbHandler.getDb() db = self.dbHandler.getDb()
cursor = db.cursor() cursor = db.cursor()
@ -197,7 +197,7 @@ class Note(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
try: try:
noteid = int(noteid) noteid = int(noteid)
@ -247,7 +247,7 @@ class Note(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
db = self.dbHandler.getDb() db = self.dbHandler.getDb()
cursor = db.cursor() cursor = db.cursor()
@ -270,7 +270,7 @@ class Note(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
db = self.dbHandler.getDb() db = self.dbHandler.getDb()
cursor = db.cursor() cursor = db.cursor()

View File

@ -138,7 +138,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
try: try:
userId = ircdb.users.getUserId(msg.prefix) userId = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()
@ -187,7 +187,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
try: try:
userId = ircdb.users.getUserId(msg.prefix) userId = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()
@ -237,7 +237,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
try: try:
userId = ircdb.users.getUserId(msg.prefix) userId = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()

View File

@ -125,7 +125,7 @@ class Todo(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
cursor.execute("""SELECT id, task FROM todo cursor.execute("""SELECT id, task FROM todo
WHERE userid = %s AND active = 1 WHERE userid = %s AND active = 1
@ -186,7 +186,7 @@ class Todo(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
(optlist, rest) = getopt.getopt(args, '', ['priority=']) (optlist, rest) = getopt.getopt(args, '', ['priority='])
priority = 0 priority = 0
@ -218,7 +218,7 @@ class Todo(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
taskids = privmsgs.getArgs(args) taskids = privmsgs.getArgs(args)
tasks = taskids.split() tasks = taskids.split()
@ -256,7 +256,7 @@ class Todo(callbacks.Privmsg):
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
(optlist, rest) = getopt.getopt(args, '', ['regexp=']) (optlist, rest) = getopt.getopt(args, '', ['regexp='])
if not optlist and not rest: if not optlist and not rest:
@ -301,7 +301,7 @@ class Todo(callbacks.Privmsg):
try: try:
user_id = ircdb.users.getUserId(msg.prefix) user_id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
(id, priority) = privmsgs.getArgs(args, required=2) (id, priority) = privmsgs.getArgs(args, required=2)
db = self.dbHandler.getDb() db = self.dbHandler.getDb()
@ -329,7 +329,7 @@ class Todo(callbacks.Privmsg):
try: try:
userid = ircdb.users.getUserId(msg.prefix) userid = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
taskid, regexp = privmsgs.getArgs(args, required=2) taskid, regexp = privmsgs.getArgs(args, required=2)
# Check the regexp first, it's easier and doesn't require a db query # Check the regexp first, it's easier and doesn't require a db query

View File

@ -303,7 +303,7 @@ class User(callbacks.Privmsg):
else: else:
irc.reply(repr(user.hostmasks)) irc.reply(repr(user.hostmasks))
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
def capabilities(self, irc, msg, args): def capabilities(self, irc, msg, args):
"""[<name>] """[<name>]
@ -371,7 +371,7 @@ class User(callbacks.Privmsg):
user = ircdb.users.getUser(msg.prefix) user = ircdb.users.getUser(msg.prefix)
irc.reply(user.name) irc.reply(user.name)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
def setsecure(self, irc, msg, args): def setsecure(self, irc, msg, args):
"""<password> [<True|False>] """<password> [<True|False>]
@ -389,7 +389,7 @@ class User(callbacks.Privmsg):
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
user = ircdb.users.getUser(id) user = ircdb.users.getUser(id)
except KeyError: except KeyError:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
if value == '': if value == '':
value = not user.secure value = not user.secure
elif value.lower() in ('true', 'false'): elif value.lower() in ('true', 'false'):

View File

@ -271,7 +271,7 @@ def formatArgumentError(method, name=None):
else: else:
return 'Invalid arguments for %s.' % method.__name__ return 'Invalid arguments for %s.' % method.__name__
def checkCommandCapability(msg, command): def checkCommandCapability(msg, cb, command):
anticap = ircdb.makeAntiCapability(command) anticap = ircdb.makeAntiCapability(command)
if ircdb.checkCapability(msg.prefix, anticap): if ircdb.checkCapability(msg.prefix, anticap):
log.info('Preventing because of anticap: %s', msg.prefix) log.info('Preventing because of anticap: %s', msg.prefix)
@ -409,8 +409,8 @@ class IrcObjectProxy(RichReplyMethods):
else: else:
del self.args[0] del self.args[0]
cb = cbs[0] cb = cbs[0]
if not checkCommandCapability(self.msg, name): if not checkCommandCapability(self.msg, cb, name):
self.error(conf.replyNoCapability % name) self.errorNoCapability(name)
return return
command = getattr(cb, name) command = getattr(cb, name)
Privmsg.handled = True Privmsg.handled = True
@ -636,8 +636,8 @@ class Privmsg(irclib.IrcCallback):
if name == canonicalName(self.name()): if name == canonicalName(self.name()):
handleBadArgs() handleBadArgs()
elif self.isCommand(name): elif self.isCommand(name):
if not checkCommandCapability(msg, name): if not checkCommandCapability(msg, self, name):
irc.error(conf.replyNoCapability % name) irc.errorNoCapability(name)
return return
del args[0] del args[0]
method = getattr(self, name) method = getattr(self, name)

View File

@ -143,7 +143,7 @@ def name(f):
name = ircdb.users.getUser(msg.prefix).name name = ircdb.users.getUser(msg.prefix).name
except KeyError: except KeyError:
if conf.requireRegistration: if conf.requireRegistration:
irc.error(conf.replyNotRegistered) irc.errorNotRegistered()
return return
else: else:
name = msg.prefix name = msg.prefix