omano
Member
I'm writing a script to ba able to set a command that will play set track.
Here is where I am:
So I have two main problems:
- The track you configure from web interface does not appear to be loaded in webinterface, but I see that it is saved to the database
- The track saved to database is like "artist - title" instead of useable "track://f609f7bf-3022-4f8d-b7f9-02fe6defbeb5" so I can not use the play('track://f609f7bf-3022-4f8d-b7f9-02fe6defbeb5') thing like in my two tries at bottom of script..
Is there a reason why my tracks do not save in the web interface config page (actually they save but does not show up). I had it to work only once after I installed the beta 0.99 bot, but it is no more showing properly.
Is there a way to use track and play to achieve what I want?
//Edit: I just noticed that if you do not click the proposed music track it does not work properly but saves the Artist - Tile to DB... I'mm investigating it will may work in the end..
Here is where I am:
PHP:
/*
*/
registerPlugin({
name: 'Commandes custom track',
version: '0',
description: 'Script supposed to assign a comand/string msg to a track',
author: 'omano',
vars: {
track_1: {
title: 'Track 1',
type: 'track',
placeholder: 'Search for track...'
},
track_2: {
title: 'Track 2',
type: 'track',
placeholder: 'Search for track...'
},
commande_1: {
title: 'Command for Track 1',
type: 'string',
placeholder: '!com1'
},
commande_2: {
title: 'Command for Track 2',
type: 'string',
placeholder: '!com2'
}
}
}, function(sinusbot, config, info){
// -- Load messages --
log('');
log('Loading...');
log('');
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-a4f6453 (and above)');
//Loading commande 1
if(typeof config.commande_1 == 'undefined' || config.commande_1 == '') {
log('No commande 1 set, using default !commande1');
var commande_1 = "!commande1";
}else{
var commande_1 = config.commande_1;
log('Commande 1: ' + commande_1);
}
//Loading commande 2
if(typeof config.commande_2 == 'undefined' || config.commande_2 == '') {
log('No commande 2 set, using default !commande2');
var commande_2 = "!commande2";
}else{
var commande_2 = config.commande_2;
log('Commande 2: ' + commande_2);
}
//Loading track 1
if(typeof config.track_1 == 'undefined' || config.track_1 == '') {
log('No track 1 set');
}else{
var track_1 = config.track_1;
log('track 1: ' + track_1);
}
//Loading track 2
if(typeof config.track_2 == 'undefined' || config.track_2 == '') {
log('No track 2 set');
}else{
var track_2 = config.track_2;
log('track 2: ' + track_2);
}
// -- Recreating "startsWith()" function which isn't included in ECMAScript 5 -- from pchannel.js
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
// -- Commandes persos
sinusbot.on('chat', function(ev) {
if (ev.msg.startsWith(commande_1)) {
play("'" + track_1 + "'");
log('lecture de ' + track_1);
}
else if (ev.msg.startsWith(commande_2)) {
play(track_2);
log('lecture de ' + track_2);
}
});
log('Loaded all!');
log('');
});
So I have two main problems:
- The track you configure from web interface does not appear to be loaded in webinterface, but I see that it is saved to the database
- The track saved to database is like "artist - title" instead of useable "track://f609f7bf-3022-4f8d-b7f9-02fe6defbeb5" so I can not use the play('track://f609f7bf-3022-4f8d-b7f9-02fe6defbeb5') thing like in my two tries at bottom of script..
Is there a reason why my tracks do not save in the web interface config page (actually they save but does not show up). I had it to work only once after I installed the beta 0.99 bot, but it is no more showing properly.
Is there a way to use track and play to achieve what I want?
//Edit: I just noticed that if you do not click the proposed music track it does not work properly but saves the Artist - Tile to DB... I'mm investigating it will may work in the end..
Last edited: