mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
add web api function for getUrl instead of string in base, use externalAddress optional config key to define external behaviours [#264]
This commit is contained in:
parent
d8342f4489
commit
677a820638
@ -21,14 +21,12 @@ var commands = function(dbot) {
|
||||
for(var i=0;i<options.length;i++) {
|
||||
polls[name]['votes'][options[i]] = 0;
|
||||
}
|
||||
|
||||
|
||||
event.reply(dbot.t('poll_created', {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'url': dbot.t('url', {
|
||||
'host': dbot.config.web.webHost,
|
||||
'port': dbot.config.web.webPort,
|
||||
'path': 'polls/' + name
|
||||
})
|
||||
'url': dbot.api.web.getUrl('/poll/' + name)
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
@ -33,7 +33,7 @@ var commands = function(dbot){
|
||||
if(event.params[1]){
|
||||
var primary = dbot.api.users.resolveUser(event.server, event.params[1]);
|
||||
if(_.has(dbot.db.profiles[event.server], primary.toLowerCase())){
|
||||
event.reply("http://"+dbot.config.web.webHost+":"+dbot.config.web.webPort+"/profile/"+event.server+"/"+primary.toLowerCase());
|
||||
event.reply(dbot.api.web.getUrl("/profile/"+event.server+"/"+primary.toLowerCase());
|
||||
}
|
||||
else{
|
||||
event.reply("No profile found for "+event.params[1]);
|
||||
|
@ -71,7 +71,6 @@ var commands = function(dbot) {
|
||||
},
|
||||
|
||||
// Search a given category for some text.
|
||||
// TODO fix
|
||||
'~qsearch': function(event) {
|
||||
var haystack = event.input[1].trim().toLowerCase();
|
||||
var needle = event.input[2];
|
||||
@ -202,11 +201,7 @@ var commands = function(dbot) {
|
||||
_.has(dbot.config.web, 'webPort')) {
|
||||
event.reply(dbot.t('quote_link', {
|
||||
'category': key,
|
||||
'url': dbot.t('url', {
|
||||
'host': dbot.config.web.webHost,
|
||||
'port': dbot.config.web.webPort,
|
||||
'path': 'quotes/' + encodeURIComponent(key)
|
||||
})
|
||||
'url': dbot.api.web.getUrl('quotes/' + encodeURIComponent(key))
|
||||
}));
|
||||
} else {
|
||||
event.reply(dbot.t('web_not_configured'));
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"webHost": "localhost",
|
||||
"webPort": 8080
|
||||
"webPort": 8080,
|
||||
"externalPath": false
|
||||
}
|
||||
|
@ -37,7 +37,17 @@ var webInterface = function(dbot) {
|
||||
|
||||
this.onDestroy = function() {
|
||||
server.close();
|
||||
}
|
||||
};
|
||||
|
||||
this.api = {
|
||||
'getUrl': function(path) {
|
||||
if(this.config.externalPath) {
|
||||
return this.config.externalPath + '/' + path;
|
||||
} else {
|
||||
return 'http://' + this.config.webHost + ':' + port + '/' + path;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
|
@ -10,8 +10,5 @@
|
||||
"es": "No se pudó cargar el módulo: {moduleName}",
|
||||
"na'vi": "Oeru Oel {moduleName}it sung.",
|
||||
"cy": "Wedi methu a llwytho modiwl: {moduleName}"
|
||||
},
|
||||
"url": {
|
||||
"en": "http://{host}:{port}/{path}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user