mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Re-add manual argument parsing since some stuff is a bit complex for wrap.
This commit is contained in:
parent
979cbd551d
commit
116f598caa
@ -172,17 +172,23 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
factoids = self._lookupFactoid(channel, key)
|
factoids = self._lookupFactoid(channel, key)
|
||||||
self._replyFactoids(irc, channel, key, factoids, error=False)
|
self._replyFactoids(irc, channel, key, factoids, error=False)
|
||||||
|
|
||||||
def whatis(self, irc, msg, args, channel, number, key):
|
def whatis(self, irc, msg, args, channel, words):
|
||||||
"""[<channel>] <key> [<number>]
|
"""[<channel>] <key> [<number>]
|
||||||
|
|
||||||
Looks up the value of <key> in the factoid database. If given a
|
Looks up the value of <key> in the factoid database. If given a
|
||||||
number, will return only that exact factoid. <channel> is only
|
number, will return only that exact factoid. <channel> is only
|
||||||
necessary if the message isn't sent in the channel itself.
|
necessary if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
|
number = None
|
||||||
|
if len(words) > 1:
|
||||||
|
if words[-1].isdigit():
|
||||||
|
number = int(words.pop())
|
||||||
|
if number <= 0:
|
||||||
|
irc.errorInvalid('key id')
|
||||||
|
key = ' '.join(words)
|
||||||
factoids = self._lookupFactoid(channel, key)
|
factoids = self._lookupFactoid(channel, key)
|
||||||
self._replyFactoids(irc, channel, key, factoids, number)
|
self._replyFactoids(irc, channel, key, factoids, number)
|
||||||
whatis = wrap(whatis, ['channel',
|
whatis = wrap(whatis, ['channel', many('something')])
|
||||||
reverse(optional('factoidId', 0)), 'text'])
|
|
||||||
|
|
||||||
def lock(self, irc, msg, args, channel, key):
|
def lock(self, irc, msg, args, channel, key):
|
||||||
"""[<channel>] <key>
|
"""[<channel>] <key>
|
||||||
@ -212,7 +218,7 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
unlock = wrap(unlock, ['channel', 'text'])
|
unlock = wrap(unlock, ['channel', 'text'])
|
||||||
|
|
||||||
def forget(self, irc, msg, args, channel, number, key):
|
def forget(self, irc, msg, args, channel, words):
|
||||||
"""[<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
|
||||||
@ -221,8 +227,16 @@ class Factoids(callbacks.Plugin, 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.
|
||||||
"""
|
"""
|
||||||
if number == '*':
|
number = None
|
||||||
number = True
|
if len(words) > 1:
|
||||||
|
if words[-1].isdigit():
|
||||||
|
number = int(words.pop())
|
||||||
|
if number <= 0:
|
||||||
|
irc.errorInvalid('key id')
|
||||||
|
elif words[-1] == '*':
|
||||||
|
words.pop()
|
||||||
|
number = True
|
||||||
|
key = ' '.join(words)
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT keys.id, factoids.id
|
cursor.execute("""SELECT keys.id, factoids.id
|
||||||
@ -253,10 +267,7 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
'Please specify which one to remove, '
|
'Please specify which one to remove, '
|
||||||
'or use * to designate all of them.' %
|
'or use * to designate all of them.' %
|
||||||
cursor.rowcount)
|
cursor.rowcount)
|
||||||
forget = wrap(forget, ['channel',
|
forget = wrap(forget, ['channel', many('something')])
|
||||||
reverse(optional(first(('literal', '*'),
|
|
||||||
'factoidId'))),
|
|
||||||
'text'])
|
|
||||||
|
|
||||||
def random(self, irc, msg, args, channel):
|
def random(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
|
Loading…
Reference in New Issue
Block a user