mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
allow remove by id, if --id is specified.
This commit is contained in:
parent
7909015288
commit
4972472764
@ -186,16 +186,22 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
|
||||
return
|
||||
add = wrap(add, ['channel', 'something', 'something'])
|
||||
|
||||
def remove(self, irc, msg, args, channel, regexp):
|
||||
"""[<channel>] <regexp>]
|
||||
def remove(self, irc, msg, args, channel, optlist, regexp):
|
||||
"""[<channel>] [--id] <regexp>]
|
||||
|
||||
Removes the trigger for <regexp> from the triggers database.
|
||||
<channel> is only necessary if
|
||||
the message isn't sent in the channel itself.
|
||||
If option --id specified, will retrieve by regexp id, not content.
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("SELECT id, locked FROM triggers WHERE regexp=?", (regexp,))
|
||||
target = 'regexp'
|
||||
for (option, arg) in optlist:
|
||||
if option == 'id':
|
||||
target = 'id'
|
||||
sql = "SELECT id, locked FROM triggers WHERE %s=?" % (target,)
|
||||
cursor.execute(sql, (regexp,))
|
||||
results = cursor.fetchall()
|
||||
if len(results) != 0:
|
||||
(id, locked) = map(int, results[0])
|
||||
@ -210,7 +216,9 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
|
||||
cursor.execute("""DELETE FROM triggers WHERE id=?""", (id,))
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
remove = wrap(remove, ['channel', 'something'])
|
||||
remove = wrap(remove, ['channel',
|
||||
getopts({'id': '',}),
|
||||
'something'])
|
||||
|
||||
def lock(self, irc, msg, args, channel, regexp):
|
||||
"""[<channel>] <regexp>
|
||||
|
Loading…
Reference in New Issue
Block a user