From 776bd6d7d67c41821c5f8006bffbdc218b9049fd Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 19 Jul 2014 19:58:22 +0000 Subject: [PATCH] dont post radio if undefined --- modules/radio/radio.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/radio/radio.js b/modules/radio/radio.js index b302be0..374ad5b 100644 --- a/modules/radio/radio.js +++ b/modules/radio/radio.js @@ -32,13 +32,15 @@ var radio = function(dbot) { stream.on('metadata', function(metadata) { var title = icecast.parseMetadata(metadata).StreamTitle; - _.each(this.config.announce, function(a) { - dbot.say(a.server, a.name, dbot.t('now_playing', { - 'name': this.data['icy-name'], - 'song': title, - 'url': this.data['icy-url'] - })); - }, this); + if(!_.isUndefined(title)) { + _.each(this.config.announce, function(a) { + dbot.say(a.server, a.name, dbot.t('now_playing', { + 'name': this.data['icy-name'], + 'song': title, + 'url': this.data['icy-url'] + })); + }, this); + } }.bind(this)); 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.internalAPI.startRadio(); dbot.api.timers.addTimer(20000, function() { - if(this.listening == false) { + if(this.listening === false) { this.internalAPI.startRadio(); } }.bind(this));