global log
params = parameter.split()
+ index = ""
+ tags = []
if len(params) == 2:
index = params[0]
tags = list(map(lambda t: t.strip(), params[1].split(",")))
+ elif len(params) == 1:
+ index = str(var.playlist.current_index + 1)
+ tags = list(map(lambda t: t.strip(), params[0].split(",")))
+ else:
+ bot.send_msg(constants.strings('bad_parameter', command=command), text)
+ return
+ if tags[0]:
if index.isdigit() and 1 <= int(index) <= len(var.playlist):
var.playlist[int(index) - 1].add_tags(tags)
log.info("cmd: add tags %s to song %s" % (", ".join(tags),
bot.send_msg(constants.strings("added_tags",
tags=", ".join(tags),
song=var.playlist[int(index) - 1].format_short_string()), text)
+ return
+
elif index == "*":
for item in var.playlist:
item.add_tags(tags)
log.info("cmd: add tags %s to song %s" % (", ".join(tags),
item.format_debug_string()))
bot.send_msg(constants.strings("added_tags_to_all", tags=", ".join(tags)), text)
- else:
- bot.send_msg(constants.strings('bad_parameter', command=command), text)
+ return
+
+ bot.send_msg(constants.strings('bad_parameter', command=command), text)
def cmd_remove_tag(bot, user, text, command, parameter):
global log
params = parameter.split()
- if len(params) == 2 and params[1]:
+
+ index = ""
+ tags = []
+ if len(params) == 2:
index = params[0]
+ tags = list(map(lambda t: t.strip(), params[1].split(",")))
+ elif len(params) == 1:
+ index = str(var.playlist.current_index + 1)
+ tags = list(map(lambda t: t.strip(), params[0].split(",")))
+ else:
+ bot.send_msg(constants.strings('bad_parameter', command=command), text)
+ return
+ if tags[0]:
if index.isdigit() and 1 <= int(index) <= len(var.playlist):
- if params[1] != "*":
- tags = list(map(lambda t: t.strip(), params[1].split(",")))
+ if tags[0] != "*":
var.playlist[int(index) - 1].remove_tags(tags)
log.info("cmd: remove tags %s from song %s" % (", ".join(tags),
var.playlist[int(index) - 1].format_debug_string()))
return
elif index == "*":
- if params[1] != "*":
- tags = list(map(lambda t: t.strip(), params[1].split(",")))
+ if tags[0] != "*":
for item in var.playlist:
item.remove_tags(tags)
log.info("cmd: remove tags %s from song %s" % (", ".join(tags),
<b>Music Library</b>
<ul>
<li> <b>!<u>se</u>arch </b> {keywords} - find item with {keywords} in the music library, keywords separated by space.</li>
- <li> <b>!<u>addt</u>ag </b> {index} {tags} - add {tags} to {index}-th item on the playlist, tags separated by ",". </li>
+ <li> <b>!<u>addt</u>ag </b> [{index}] {tags} - add {tags} to {index}-th(current song if {index} is omitted) item on the playlist, tags separated by ",". </li>
<li> <b>!<u>addt</u>ag </b> * {tags} - add {tags} to all items on the playlist. </li>
- <li> <b>!<u>un</u>tag </b> {index/*} {tags} - remove {tags} from {index}-th item on the playlist. </li>
- <li> <b>!<u>un</u>tag </b> {index/*} * - remove all tags from {index}-th item on the playlist. </li>
+ <li> <b>!<u>un</u>tag </b> [{index/*}] {tags}/* - remove {tags}/all tags from {index}-th(current song if {index} is omitted) item on the playlist. </li>
<li> <b>!<u>fin</u>dtagged </b> (or <b>!ft</b>) {tags} - find item with {tags} in the music library. </li>
<li> <b>!<u>del</u>ete </b> {index} - delete {index}-th item on the shortlist from the music library. </li>
</ul>