mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
radio
This commit is contained in:
parent
2bb307a462
commit
748b42cff0
5
modules/radio/config.json
Normal file
5
modules/radio/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"stream": "",
|
||||
"announce": [ { "server": "aberwiki", "name": "#dbot" } ],
|
||||
"outputPrefix": "\u00033radio\u000f"
|
||||
}
|
50
modules/radio/radio.js
Normal file
50
modules/radio/radio.js
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Module Name: Radio
|
||||
* Description: Various icecast functionality.
|
||||
*/
|
||||
|
||||
var _ = require('underscore')._,
|
||||
icecast = require('icecast-stack');
|
||||
|
||||
var radio = function(dbot) {
|
||||
this.listening = false;
|
||||
this.data = false;
|
||||
this.internalAPI = {
|
||||
'startRadio': function() {
|
||||
var stream = icecast.createReadStream(this.config.stream);
|
||||
|
||||
stream.on('connect', function() {
|
||||
this.listening = true;
|
||||
}.bind(this));
|
||||
|
||||
stream.on('response', function(res) {
|
||||
this.data = res.headers;
|
||||
_.each(this.config.announce, function(a) {
|
||||
dbot.say(a.server, a.name, dbot.t('now_online', {
|
||||
'name': res.headers['icy-name'],
|
||||
'desc': res.headers['icy-description'],
|
||||
'url': res.headers['icy-url']
|
||||
}));
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
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);
|
||||
}.bind(this));
|
||||
}.bind(this)
|
||||
};
|
||||
this.onLoad = function() {
|
||||
this.internalAPI.startRadio();
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return new radio(dbot);
|
||||
};
|
8
modules/radio/strings.json
Normal file
8
modules/radio/strings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"now_online": {
|
||||
"en": "Now Online: {name} - {desc} - {url}"
|
||||
},
|
||||
"now_playing": {
|
||||
"en": "Now Playing: {name} - {song} - {url}"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user