From d7399e73fa79e86b8d3dc8f2a2a9c1849f439e5b Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Mon, 13 Jan 2014 17:38:42 -0800 Subject: [PATCH] tag.py: add .untag, so each tag action has its own command --- plugins/tag.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/tag.py b/plugins/tag.py index 0653feb..14915f9 100644 --- a/plugins/tag.py +++ b/plugins/tag.py @@ -135,16 +135,12 @@ def get_nicks_by_tagset(db, chan, tagset): @hook.command def tag(inp, chan='', db=None): - '.tag [add|del] -- marks/unmarks as {related: .tags, .tagged}' + '.tag -- marks as {related: .untag, .tags, .tagged}' db.execute('create table if not exists tag(chan, subject, nick)') - add = re.match(r'(?:a(?:dd)? )?(\S+) (.+)', inp) - delete = re.match(r'd(?:el(?:ete)?)? (\S+) (.+)\s*$', inp) + add = re.match(r'(\S+) (.+)', inp) - if delete: - nick, del_tag = delete.groups() - return delete_tag(db, chan, nick, del_tag) if add: nick, subject = add.groups() return add_tag(db, chan, nick, subject) @@ -155,9 +151,21 @@ def tag(inp, chan='', db=None): else: return tag.__doc__ +@hook.command +def untag(inp, chan='', db=None): + '.untag -- unmarks as {related: .tag, .tags, .tagged}' + + delete = re.match(r'(\S+) (.+)$', inp) + + if delete: + nick, del_tag = delete.groups() + return delete_tag(db, chan, nick, del_tag) + else: + return untag.__doc__ + @hook.command def tags(inp, chan='', db=None): - '.tags /list -- get list of tags for , or a list of tags {related: .tag, .tagged}' + '.tags /list -- get list of tags for , or a list of tags {related: .tag, .untag, .tagged}' if inp == 'list': return get_tag_counts_by_chan(db, chan) @@ -170,7 +178,7 @@ def tags(inp, chan='', db=None): @hook.command def tagged(inp, chan='', db=None): - '.tagged [& tag...] -- get nicks marked as (separate multiple tags with &) {related: .tag, .tags}' + '.tagged [& tag...] -- get nicks marked as (separate multiple tags with &) {related: .tag, .untag, .tags}' return get_nicks_by_tagset(db, chan, inp)