dont post radio if undefined

This commit is contained in:
reality 2014-07-19 19:58:22 +00:00
parent aab0e8b6db
commit 776bd6d7d6

View File

@ -32,13 +32,15 @@ var radio = function(dbot) {
stream.on('metadata', function(metadata) { stream.on('metadata', function(metadata) {
var title = icecast.parseMetadata(metadata).StreamTitle; var title = icecast.parseMetadata(metadata).StreamTitle;
_.each(this.config.announce, function(a) { if(!_.isUndefined(title)) {
dbot.say(a.server, a.name, dbot.t('now_playing', { _.each(this.config.announce, function(a) {
'name': this.data['icy-name'], dbot.say(a.server, a.name, dbot.t('now_playing', {
'song': title, 'name': this.data['icy-name'],
'url': this.data['icy-url'] 'song': title,
})); 'url': this.data['icy-url']
}, this); }));
}, this);
}
}.bind(this)); }.bind(this));
stream.on('end', function() { stream.on('end', function() {
@ -65,12 +67,12 @@ var radio = function(dbot) {
}); });
} }
}; };
this.commands['~request'].regex = [/^request ([\d\w\s-]*)/, 2]; this.commands['~request'].regex = [/^request (.*)/, 2];
this.onLoad = function() { this.onLoad = function() {
this.internalAPI.startRadio(); this.internalAPI.startRadio();
dbot.api.timers.addTimer(20000, function() { dbot.api.timers.addTimer(20000, function() {
if(this.listening == false) { if(this.listening === false) {
this.internalAPI.startRadio(); this.internalAPI.startRadio();
} }
}.bind(this)); }.bind(this));