mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Reverted accidental commit.
This commit is contained in:
parent
0a2802f56e
commit
f8a6f2c95d
@ -275,7 +275,8 @@ class Debian(callbacks.Privmsg,
|
|||||||
r = utils.perlReToPythonRe(arg)
|
r = utils.perlReToPythonRe(arg)
|
||||||
predicates.append(r.search)
|
predicates.append(r.search)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('regular expression', arg, Raise=True)
|
irc.error('%r is not a valid regexp.' % arg)
|
||||||
|
return
|
||||||
elif option == '--arch':
|
elif option == '--arch':
|
||||||
arg = '_%s.' % arg
|
arg = '_%s.' % arg
|
||||||
archPredicate = lambda s, arg=arg: (arg in s)
|
archPredicate = lambda s, arg=arg: (arg in s)
|
||||||
|
@ -194,7 +194,8 @@ class Dunno(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.error('id', id, Raise=True)
|
irc.error('Invalid id: %r' % id)
|
||||||
|
return
|
||||||
dunno = self.db.get(channel, id)
|
dunno = self.db.get(channel, id)
|
||||||
if by != dunno.by:
|
if by != dunno.by:
|
||||||
cap = ircdb.makeChannelCapability(channel, 'op')
|
cap = ircdb.makeChannelCapability(channel, 'op')
|
||||||
@ -237,7 +238,8 @@ class Dunno(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('dunno id', id, Raise=True)
|
irc.error('%r is not a valid dunno id.' % id)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
dunno = self.db.get(channel, id)
|
dunno = self.db.get(channel, id)
|
||||||
name = ircdb.users.getUser(dunno.by).name
|
name = ircdb.users.getUser(dunno.by).name
|
||||||
@ -266,15 +268,18 @@ class Dunno(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('dunno id', id, Raise=True)
|
irc.error('%r is not a valid dunno id.' % id)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
_ = self.db.get(channel, id)
|
_ = self.db.get(channel, id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('There is no dunno #%s.' % id)
|
irc.error('There is no dunno #%s.' % id)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
except:
|
except:
|
||||||
irc.errorInvalid('regular expression', regexp, Raise=True)
|
irc.error('%r is not a valid regular expression.' % regexp)
|
||||||
|
return
|
||||||
self.db.change(channel, id, replacer)
|
self.db.change(channel, id, replacer)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
|
@ -171,7 +171,8 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
irc.reply(factoids[number-1])
|
irc.reply(factoids[number-1])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.errorInvalid('number for that key', number, Raise=True)
|
irc.error('That\'s not a valid number for that key.')
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
intro = self.registryValue('factoidPrefix', channel)
|
intro = self.registryValue('factoidPrefix', channel)
|
||||||
prefix = '%r %s' % (key, intro)
|
prefix = '%r %s' % (key, intro)
|
||||||
@ -213,7 +214,8 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
number = int(number)
|
number = int(number)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('number', number, Raise=True)
|
irc.error('%s is not a valid number.' % number)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
number = 0
|
number = 0
|
||||||
factoids = self._lookupFactoid(channel, key)
|
factoids = self._lookupFactoid(channel, key)
|
||||||
@ -291,7 +293,8 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
(_, id) = results[number]
|
(_, id) = results[number]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.errorInvalid('factoid number', number, Raise=True)
|
irc.error('Invalid factoid number.')
|
||||||
|
return
|
||||||
cursor.execute("DELETE FROM factoids WHERE id=%s", id)
|
cursor.execute("DELETE FROM factoids WHERE id=%s", id)
|
||||||
db.commit()
|
db.commit()
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
@ -367,13 +370,15 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.errorInvalid('regular expression', regexp, str(e), Raise=True)
|
irc.error('Invalid regexp: %s' % e)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
number = int(number)
|
number = int(number)
|
||||||
if number <= 0:
|
if number <= 0:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('id', number, Raise=True)
|
irc.error('Invalid key id.')
|
||||||
|
return
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT factoids.id, factoids.fact
|
cursor.execute("""SELECT factoids.id, factoids.fact
|
||||||
|
@ -252,7 +252,8 @@ class Herald(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
changer = utils.perlReToReplacer(regexp)
|
changer = utils.perlReToReplacer(regexp)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.errorInvalid('regular expression', regexp, str(e), Raise=True)
|
irc.error('That\'s not a valid regexp: %s.' % e)
|
||||||
|
return
|
||||||
s = self.db[channel, id]
|
s = self.db[channel, id]
|
||||||
newS = changer(s)
|
newS = changer(s)
|
||||||
self.db[channel, id] = newS
|
self.db[channel, id] = newS
|
||||||
|
@ -133,7 +133,8 @@ class Lookup(callbacks.Privmsg):
|
|||||||
name = privmsgs.getArgs(args)
|
name = privmsgs.getArgs(args)
|
||||||
name = callbacks.canonicalName(name)
|
name = callbacks.canonicalName(name)
|
||||||
if name not in self.lookupDomains:
|
if name not in self.lookupDomains:
|
||||||
irc.errorInvalid('lookup', name, Raise=True)
|
irc.error('That\'s not a valid lookup to remove.')
|
||||||
|
return
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
try:
|
try:
|
||||||
@ -248,7 +249,9 @@ class Lookup(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
r = utils.perlReToPythonRe(arg)
|
r = utils.perlReToPythonRe(arg)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.errorInvalid('regular expression', arg, Raise=True)
|
irc.error('%r is not a valid regular expression' %
|
||||||
|
arg)
|
||||||
|
return
|
||||||
def p(s, r=r):
|
def p(s, r=r):
|
||||||
return int(bool(r.search(s)))
|
return int(bool(r.search(s)))
|
||||||
db.create_function(predicateName, 1, p)
|
db.create_function(predicateName, 1, p)
|
||||||
|
@ -194,7 +194,7 @@ class Observer(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
name = privmsgs.getArgs(args)
|
name = privmsgs.getArgs(args)
|
||||||
if name not in self.registryValue('observers'):
|
if name not in self.registryValue('observers'):
|
||||||
irc.errorInvalid('observer', name, Raise=True)
|
irc.error('That\'s not a valid observer.', Raise=True)
|
||||||
g = self.registryValue('observers.%s' % name, value=False)
|
g = self.registryValue('observers.%s' % name, value=False)
|
||||||
regexp = g()
|
regexp = g()
|
||||||
command = g.command()
|
command = g.command()
|
||||||
@ -222,9 +222,8 @@ class Observer(callbacks.Privmsg):
|
|||||||
probability = 1.0
|
probability = 1.0
|
||||||
(name, regexp, command) = privmsgs.getArgs(args, required=3)
|
(name, regexp, command) = privmsgs.getArgs(args, required=3)
|
||||||
if not registry.isValidRegistryName(name):
|
if not registry.isValidRegistryName(name):
|
||||||
irc.errorInvalid('observer name', name,
|
irc.error('That\'s not a valid observer name. Please be sure '
|
||||||
'Please be sure there are no spaces in the name.',
|
'there are no spaces in the name.', Raise=True)
|
||||||
Raise=True)
|
|
||||||
registerObserver(name, regexp, command, probability)
|
registerObserver(name, regexp, command, probability)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
|
@ -323,7 +323,8 @@ class Quotes(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('id', id, Raise=True)
|
irc.error('Invalid id: %r' % id)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
quote = self.db.get(channel, id)
|
quote = self.db.get(channel, id)
|
||||||
irc.reply(str(quote))
|
irc.reply(str(quote))
|
||||||
@ -341,7 +342,7 @@ class Quotes(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('id', id, Raise=True)
|
irc.error('That\'s not a valid id: %r' % id)
|
||||||
try:
|
try:
|
||||||
self.db.remove(channel, id)
|
self.db.remove(channel, id)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
@ -112,7 +112,9 @@ class Todo(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
userid = ircdb.users.getUserId(arg)
|
userid = ircdb.users.getUserId(arg)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.errorInvalid('task or username', arg, Raise=True)
|
irc.error(
|
||||||
|
'%r is not a valid task id or username' % arg)
|
||||||
|
return
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
if not userid and not taskid:
|
if not userid and not taskid:
|
||||||
@ -149,7 +151,8 @@ class Todo(callbacks.Privmsg):
|
|||||||
cursor.execute("""SELECT userid,priority,added_at,task,active
|
cursor.execute("""SELECT userid,priority,added_at,task,active
|
||||||
FROM todo WHERE id = %s""", taskid)
|
FROM todo WHERE id = %s""", taskid)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.errorInvalid('task id', taskid, Raise=True)
|
irc.error('%r is not a valid task id' % taskid)
|
||||||
|
return
|
||||||
(userid, pri, added_at, task, active) = cursor.fetchone()
|
(userid, pri, added_at, task, active) = cursor.fetchone()
|
||||||
# Construct and return the reply
|
# Construct and return the reply
|
||||||
user = ircdb.users.getUser(userid)
|
user = ircdb.users.getUser(userid)
|
||||||
@ -188,7 +191,8 @@ class Todo(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
priority = int(arg)
|
priority = int(arg)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.errorInvalid('priority', arg, Raise=True)
|
irc.error('%r is an invalid priority' % arg)
|
||||||
|
return
|
||||||
text = privmsgs.getArgs(rest)
|
text = privmsgs.getArgs(rest)
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
@ -268,7 +272,9 @@ class Todo(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
r = utils.perlReToPythonRe(arg)
|
r = utils.perlReToPythonRe(arg)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.errorInvalid('regular expression', arg, Raise=True)
|
irc.error('%r is not a valid regular expression' %
|
||||||
|
arg)
|
||||||
|
return
|
||||||
def p(s, r=r):
|
def p(s, r=r):
|
||||||
return int(bool(r.search(s)))
|
return int(bool(r.search(s)))
|
||||||
db.create_function(predicateName, 1, p)
|
db.create_function(predicateName, 1, p)
|
||||||
@ -331,17 +337,19 @@ class Todo(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.errorInvalid('regular expression', regexp, Raise=True)
|
irc.error('%r is not a valid regexp' % regexp)
|
||||||
|
return
|
||||||
db = self.dbHandler.getDb()
|
db = self.dbHandler.getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT task FROM todo
|
cursor.execute("""SELECT task FROM todo
|
||||||
WHERE userid = %s AND id = %s
|
WHERE userid = %s AND id = %s
|
||||||
AND active = 1""", userid, taskid)
|
AND active = 1""", userid, taskid)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.errorInvalid('task id', taskid, Raise=True)
|
irc.error('%r is not a valid task id' % taskid)
|
||||||
|
return
|
||||||
newtext = replacer(cursor.fetchone()[0])
|
newtext = replacer(cursor.fetchone()[0])
|
||||||
cursor.execute("""UPDATE todo SET task = %s WHERE id = %s""",
|
cursor.execute("""UPDATE todo SET task = %s
|
||||||
newtext, taskid)
|
WHERE id = %s""", newtext, taskid)
|
||||||
db.commit()
|
db.commit()
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
n += len(topics)
|
n += len(topics)
|
||||||
return n
|
return n
|
||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
irc.errorInvalid('topic number', n, Raise=True)
|
irc.error('That\'s not a valid topic number.', Raise=True)
|
||||||
|
|
||||||
def topic(self, irc, msg, args, channel):
|
def topic(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
@ -308,12 +308,14 @@ class Topic(callbacks.Privmsg):
|
|||||||
(number, regexp) = privmsgs.getArgs(args, required=2)
|
(number, regexp) = privmsgs.getArgs(args, required=2)
|
||||||
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
||||||
if not topics:
|
if not topics:
|
||||||
irc.error('There are no topics to change.', Raise=True)
|
irc.error('There are no topics to change.')
|
||||||
|
return
|
||||||
number = self._topicNumber(irc, number, topics=topics)
|
number = self._topicNumber(irc, number, topics=topics)
|
||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.errorInvalid('regexp', regexp, Raise=True)
|
irc.error('The regexp wasn\'t valid: %s' % e)
|
||||||
|
return
|
||||||
topics[number] = replacer(topics[number])
|
topics[number] = replacer(topics[number])
|
||||||
self._sendTopics(irc, channel, topics)
|
self._sendTopics(irc, channel, topics)
|
||||||
change = privmsgs.channel(change)
|
change = privmsgs.channel(change)
|
||||||
|
@ -303,10 +303,10 @@ class Words(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
# User input an invalid character
|
# User input an invalid character
|
||||||
if len(letter) == 1:
|
if len(letter) == 1:
|
||||||
irc.errorInvalid('letter', letter, Raise=True)
|
irc.error('That is not a valid letter.')
|
||||||
# User input an invalid word (len(try) != len(hidden))
|
# User input an invalid word (len(try) != len(hidden))
|
||||||
else:
|
else:
|
||||||
irc.errorInvalid('word guess', letter, Raise=True)
|
irc.error('That is not a valid word guess.')
|
||||||
# Verify if the user won or lost
|
# Verify if the user won or lost
|
||||||
if game.guessed and game.tries > 0:
|
if game.guessed and game.tries > 0:
|
||||||
self._hangmanReply(irc, channel,
|
self._hangmanReply(irc, channel,
|
||||||
|
Loading…
Reference in New Issue
Block a user