From db25eadedff01751c1c324093d43877ea5e20632 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 20 Jul 2015 15:13:01 +0000 Subject: [PATCH] only post a radio update every 2 minutes --- modules/radio/radio.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/radio/radio.js b/modules/radio/radio.js index aa91061..75cdff2 100644 --- a/modules/radio/radio.js +++ b/modules/radio/radio.js @@ -11,6 +11,7 @@ var radio = function(dbot) { this.data = false; this.title = false; this.stream = false; + this.recentUpdate = false; this.internalAPI = { 'startRadio': function() { var stream = icecast.createReadStream(this.config.stream); @@ -37,11 +38,14 @@ var radio = function(dbot) { this.title = icecast.parseMetadata(metadata).StreamTitle; if(!_.isUndefined(this.title) && this.data['icy-name']) { // sowwy jesus _.each(this.config.announce, function(a) { + if(!this.recentUpdate) { dbot.say(a.server, a.name, dbot.t('now_playing', { 'name': this.data['icy-name'], 'song': this.title, 'url': this.data['icy-url'] })); + recentUpdate = true; + } }, this); } }.bind(this)); @@ -91,6 +95,10 @@ var radio = function(dbot) { this.internalAPI.startRadio(); } }.bind(this)); + + dbot.api.timers.addTimer(120000, function() { + this.recentUpdate = false; + }.bind(this)); }.bind(this); this.onDestroy = function() { this.stream.end();