registerPlugin({
name: 'Change codec',
version: '1.0',
description: 'This script implements the .codec command to change the bot channels codec.',
author: 'good_live',
vars: {
cmd: {
title: 'The command to trigger. (Exampel .codec)',
type: 'string',
placeholder: '.codec'
}
}
}, function(sinusbot, config, info) {
// -- Load messages --
log('Loading...');
var author = info.author.split(',');
if(author.length == 1){
author = author[0];
author = author.replace(/<.*>/gi, '').trim();
} else {
author = author.map(function(e){
return e.replace(/<.*>/gi, '').trim();
});
author = author.join(' & ');
}
log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-50e8ba1 (and above)');
// -- Recreating "startsWith()" function which isn't included in ECMAScript 5 --
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
//Loading cmd variable
if(typeof config.cmd == "undefined" || !config.cmd) {
var cmd = '.codec';
log('No cmd set ... using the default one: ".codec"');
}else{
var cmd = config.cmd;
}
sinusbot.on('chat', function(ev) {
if(ev.mode != 1) return;
if(ev.msg.startsWith(cmd)){
var buffer = ev.msg.replace(cmd, '').trim().toLowerCase();
switch(true) {
case buffer.startsWith('narrow'):
channelUpdate(getCurrentChannelId(), { codec: 0 });
break;
case buffer.startsWith('wide'):
channelUpdate(getCurrentChannelId(), { codec: 1 });
break;
case buffer.startsWith('ultrawide'):
channelUpdate(getCurrentChannelId(), { codec: 2 });
break;
case buffer.startsWith('mono'):
channelUpdate(getCurrentChannelId(), { codec: 3 });
break;
case buffer.startsWith('voice'):
channelUpdate(getCurrentChannelId(), { codec: 4 });
break;
case buffer.startsWith('music'):
channelUpdate(getCurrentChannelId(), { codec: 5 });
break;
case buffer.startsWith('help'):
chatPrivate(ev.clientId, 'Help page for the ' + cmd + ' command:');
chatPrivate(ev.clientId, cmd + ' narrow (changes the codec to Narrowband)');
chatPrivate(ev.clientId, cmd + ' wide (changes the codec to Wideband)');
chatPrivate(ev.clientId, cmd + ' ultrawide (changes the codec to Ultra-wideband)');
chatPrivate(ev.clientId, cmd + ' mono (changes the codec to CELT Mono)');
chatPrivate(ev.clientId, cmd + ' voice (changes the codec to Opus Voice)');
chatPrivate(ev.clientId, cmd + ' music (changes the codec to Opus Music)');
break;
default:
chatPrivate(ev.clientId, 'Usage: ' + cmd + ' <narrow|wide|ultrawide|mono|voice|music|help>');
break;
}
}
return;
});
// -- Information --
log('Loaded !');
});
registerPlugin({
name: 'Change codec',
version: '1.0',
description: 'This script implements the .codec command to change the bot channels codec.',
author: 'good_live',
vars: {
cmd: {
title: 'The command to trigger. (Exampel .codec)',
type: 'string',
placeholder: '.codec'
}
}
}, function(sinusbot, config, info) {
// -- Load messages --
log('Loading...');
var author = info.author.split(',');
if(author.length == 1){
author = author[0];
author = author.replace(/<.*>/gi, '').trim();
} else {
author = author.map(function(e){
return e.replace(/<.*>/gi, '').trim();
});
author = author.join(' & ');
}
log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-50e8ba1 (and above)');
// -- Recreating "startsWith()" function which isn't included in ECMAScript 5 --
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
//Loading cmd variable
if(typeof config.cmd == "undefined" || !config.cmd) {
var cmd = '.codec';
log('No cmd set ... using the default one: ".codec"');
}else{
var cmd = config.cmd;
}
sinusbot.on('chat', function(ev) {
if(ev.mode != 1) return;
if(ev.msg.startsWith(cmd)){
var channels = getChannels();
var i;
for (i=0; i<channels.length; i++){
if(channels[i].id == getCurrentChannelId()){
if(channels[i].codec == 5){
channelUpdate(getCurrentChannelId(), { codec: 4 });
chatPrivate(ev.clientId, 'Changed the codec to Voice.');
}else{
channelUpdate(getCurrentChannelId(), { codec: 5 });
chatPrivate(ev.clientId, 'Changed the codec to Music.');
}
}
}
}
return;
});
// -- Information --
log('Loaded !');
});
registerPlugin({
name: 'Change codec',
version: '1.1',
description: 'This script implements the .codec command to change the bot channels codec.',
author: 'good_live',
vars: {
cmd: {
title: 'The command to trigger. (Exampel .codec)',
type: 'string',
placeholder: '.codec'
}
groupids: {
title: 'IDs of the groups or clients that are allowed to use the command. (Leave it empty to allow everybody)',
type: 'string',
placeholder: '12 120 319EN4I/TuSji8VPdK7drJtELn0= 49'
}
}
}, function(sinusbot, config, info) {
// -- Load messages --
log('Loading...');
var author = info.author.split(',');
if(author.length == 1){
author = author[0];
author = author.replace(/<.*>/gi, '').trim();
} else {
author = author.map(function(e){
return e.replace(/<.*>/gi, '').trim();
});
author = author.join(' & ');
}
log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-8f70ff3 (and above)');
// -- Recreating "startsWith()" function which isn't included in ECMAScript 5 --
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
//Loading cmd variable
if(typeof config.cmd == "undefined" || !config.cmd) {
var cmd = '.codec';
log('No cmd set ... using the default one: ".codec"');
}else{
var cmd = config.cmd;
}
//Loading group/clientids
if(typeof config.groupids == 'undefined' || config.groupids == '') {
log('No group/client ids set! Everybody is allowed to create a private channel.');
var groupids = "0";
}else{
var groupids = config.groupids.split(' ');
}
//Function to check if a user has the permission to execute the cmd
function haspermission(clientUid, clientGroups){
var j;
for (j=0; j<groupids.length; j++){
if(groupids[j] == clientUid){
return true;
}else{
var s;
for(s=0; s<clientGroups.length; s++){
if (clientGroups[s].i == groupids[j]) {
return true;
}
}
}
}
return false;
}
sinusbot.on('chat', function(ev) {
if(ev.mode != 1) return;
if(ev.msg.startsWith(cmd)){
if(groupids == '0' || haspermission(ev.clientUid, ev.clientServerGroups)){
var channels = getChannels();
var i;
for (i=0; i<channels.length; i++){
if(channels[i].id == getCurrentChannelId()){
if(channels[i].codec == 5){
channelUpdate(getCurrentChannelId(), { codec: 4 });
chatPrivate(ev.clientId, 'Changed the codec to Voice.');
return;
}else{
channelUpdate(getCurrentChannelId(), { codec: 5 });
chatPrivate(ev.clientId, 'Changed the codec to Music.');
return;
}
}
}
}
}
return;
});
// -- Information --
log('Loaded !');
});
good day to all.
mb someone upgrade the scripts, if posible!
when the bot come in the room, then codec was changed to opus music
when the bot leave the room, then codec was changed to opus voice
Ive done something like that already. Should be somewhere around in the forumgood day to all.
mb someone upgrade the scripts, if posible!
when the bot come in the room, then codec was changed to opus music
when the bot leave the room, then codec was changed to opus voice
Hey,
ich hab das ganze mal mehr oder weniger umgesetzt: musicchannel.
Allerdings kann/wird es Probleme geben, wenn mehrere musicbots in einem Channel sind.
Außerdem wird der Codec beim disconnect nicht zurückgesetzt (geht iwie nicht mit der disconnect Funktion :/), aber sobald der bot wieder drauf joint prüft er den alten Channel nochmal und setzt den Codec da auch ggf wieder zurück.
Du kannst das script ja mal ausgiebig testen und dich mit Verbesserungswünschen melden.
Maybe you should read just a few posts above.Would it be possible to auto change the codec to opus music or a specific codec as soon as the bot is moved to/enters a channel?