mirror of https://github.com/calzoneman/sync.git
Added /cleantitle, and -i option to ignore case.
Fix #257, you should be able to clear username and title patterns now with ease. For best results, wait until they've wasted a lot of time adding a lot of videos before you wipe them.
This commit is contained in:
parent
48de471064
commit
507a97b4db
|
@ -91,6 +91,9 @@ function handle(chan, user, msg, data) {
|
||||||
else if(msg.indexOf("/clean ") == 0) {
|
else if(msg.indexOf("/clean ") == 0) {
|
||||||
handleClean(chan, user, msg.substring(7));
|
handleClean(chan, user, msg.substring(7));
|
||||||
}
|
}
|
||||||
|
else if(msg.indexOf("/cleantitle ") == 0) {
|
||||||
|
handleCleanTitle(chan, user, msg.substring(12));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMute(chan, user, args) {
|
function handleMute(chan, user, args) {
|
||||||
|
@ -243,24 +246,45 @@ function handleClear(chan, user) {
|
||||||
chan.sendAll("clearchat");
|
chan.sendAll("clearchat");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var user_input_re = /^(-[img]+\s+)/i
|
||||||
|
|
||||||
|
function user_input_regexp(target) {
|
||||||
|
var m = target.match(user_input_re);
|
||||||
|
var flags = "";
|
||||||
|
if (m) {
|
||||||
|
flags = m[0].slice(1,-1);
|
||||||
|
target = target.replace(user_input_re, "");
|
||||||
|
}
|
||||||
|
return new RegExp(target, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClean(chan, user, target) {
|
||||||
|
// you can use regexps, in case someone tries
|
||||||
|
// to fool you with cyrillic or something.
|
||||||
|
target = user_input_regexp(target);
|
||||||
|
cleanPlaylist(chan, user, function(item) {
|
||||||
|
return target.test(item.queueby);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCleanTitle(chan, user, target) {
|
||||||
|
target = user_input_regexp(target);
|
||||||
|
cleanPlaylist(chan, user, function(item) {
|
||||||
|
return target.exec(item.media.title) !== null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Remove all videos by a particular user.
|
Remove all videos by a particular user.
|
||||||
*/
|
*/
|
||||||
function handleClean(chan, user, target) {
|
function cleanPlaylist(chan, user, filter) {
|
||||||
if(!chan.hasPermission(user, "playlistdelete")) {
|
if(!chan.hasPermission(user, "playlistdelete")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// you can use regexps, in case someone tries
|
|
||||||
// to fool you with cyrillic or something.
|
|
||||||
target = new RegExp(target);
|
|
||||||
// local variables for deleteNext() callback
|
// local variables for deleteNext() callback
|
||||||
var pl = chan.playlist;
|
var pl = chan.playlist;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var matches = pl.items.findAll(function(item) {
|
var matches = pl.items.findAll(filter);
|
||||||
return target.test(item.queueby);
|
|
||||||
});
|
|
||||||
console.log(matches);
|
|
||||||
var deleteNext;
|
var deleteNext;
|
||||||
deleteNext = function() {
|
deleteNext = function() {
|
||||||
if (count < matches.length) {
|
if (count < matches.length) {
|
||||||
|
|
Loading…
Reference in New Issue