registerPlugin({
name: 'notSame',
version: '0.1',
backends: ['ts3'],
description: 'Block creating channels with the same name',
author: 'DrWarpMan',
vars: []
}, function(sinusbot, config) {
var engine = require('engine');
var backend = require('backend');
var event = require('event');
event.on('channelCreate', function(ev) {
var CH = backend.getChannelByID(ev.id());
CH.setName("Hello");
});
}
});
registerPlugin({
name: 'channelNameChecker',
version: '0.1',
description: 'Checks if a channelname already exists, if so, the new channel will be deleted.',
author: 'Everlike <[email protected]>'
vars: []
}, function (sinusbot, config) {
var engine = require ('engine');
var backend = require ('backend');
var event = require ('event');
setTimeout(function(){
event.on('channelCreate', function (ev) {
if (getAllChannelNames().indexOf(ev.name()) >= 0) {
ev.delete();
// ev.invoker.chat("Sorry, this channelname already exists, choose another oneplease");
}
});
}, 20000);
function getAllChannelNames() {
var allChannelNames = [];
var allChannels = backend.getChannels();
for (i = 0; i < allChannels.length; i++) {
allChannelNames.push(allChannels[i].name());
}
return allChannelNames;
};
});
registerPlugin({
name: 'channelNameChecker',
version: '0.1',
description: 'Checks if a channelname already exists, if so, the new channel will be deleted.',
author: 'Everlike <[email protected]> & DrWarpMan',
vars: []
}, function (sinusbot, config) {
var engine = require ('engine');
var backend = require ('backend');
var event = require ('event');
setTimeout(function(){
event.on('channelCreate', function (ev) {
var x = getAllChannelNames(); // all channels
// remove the created channel from array
for (var i=x.length-1; i>=0; i--) {
if (x[i] === ev.name()) {
x.splice(i, 1);
break; // remove only the first time
}
};
// if channel with the same name exists
if (x.indexOf(ev.name()) >= 0)
{
// do this
var newName = ev.name().slice(0, ev.name().length-1); // remove last character from the name
ev.setName(newName); // set the name
}
});
}, 20000);
// getting all channels' names
function getAllChannelNames() {
var allChannelNames = [];
var allChannels = backend.getChannels();
for (i = 0; i < allChannels.length; i++) {
allChannelNames.push(allChannels[i].name());
}
return allChannelNames;
};
});