mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +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++) {
|
for(var i=0;i<options.length;i++) {
|
||||||
polls[name]['votes'][options[i]] = 0;
|
polls[name]['votes'][options[i]] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event.reply(dbot.t('poll_created', {
|
event.reply(dbot.t('poll_created', {
|
||||||
'name': name,
|
'name': name,
|
||||||
'description': description,
|
'description': description,
|
||||||
'url': dbot.t('url', {
|
'url': dbot.api.web.getUrl('/poll/' + name)
|
||||||
'host': dbot.config.web.webHost,
|
|
||||||
'port': dbot.config.web.webPort,
|
|
||||||
'path': 'polls/' + name
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ var commands = function(dbot){
|
|||||||
if(event.params[1]){
|
if(event.params[1]){
|
||||||
var primary = dbot.api.users.resolveUser(event.server, event.params[1]);
|
var primary = dbot.api.users.resolveUser(event.server, event.params[1]);
|
||||||
if(_.has(dbot.db.profiles[event.server], primary.toLowerCase())){
|
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{
|
else{
|
||||||
event.reply("No profile found for "+event.params[1]);
|
event.reply("No profile found for "+event.params[1]);
|
||||||
|
@ -71,7 +71,6 @@ var commands = function(dbot) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Search a given category for some text.
|
// Search a given category for some text.
|
||||||
// TODO fix
|
|
||||||
'~qsearch': function(event) {
|
'~qsearch': function(event) {
|
||||||
var haystack = event.input[1].trim().toLowerCase();
|
var haystack = event.input[1].trim().toLowerCase();
|
||||||
var needle = event.input[2];
|
var needle = event.input[2];
|
||||||
@ -202,11 +201,7 @@ var commands = function(dbot) {
|
|||||||
_.has(dbot.config.web, 'webPort')) {
|
_.has(dbot.config.web, 'webPort')) {
|
||||||
event.reply(dbot.t('quote_link', {
|
event.reply(dbot.t('quote_link', {
|
||||||
'category': key,
|
'category': key,
|
||||||
'url': dbot.t('url', {
|
'url': dbot.api.web.getUrl('quotes/' + encodeURIComponent(key))
|
||||||
'host': dbot.config.web.webHost,
|
|
||||||
'port': dbot.config.web.webPort,
|
|
||||||
'path': 'quotes/' + encodeURIComponent(key)
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('web_not_configured'));
|
event.reply(dbot.t('web_not_configured'));
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"webHost": "localhost",
|
"webHost": "localhost",
|
||||||
"webPort": 8080
|
"webPort": 8080,
|
||||||
|
"externalPath": false
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,18 @@ var webInterface = function(dbot) {
|
|||||||
|
|
||||||
this.onDestroy = function() {
|
this.onDestroy = function() {
|
||||||
server.close();
|
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) {
|
exports.fetch = function(dbot) {
|
||||||
return new webInterface(dbot);
|
return new webInterface(dbot);
|
||||||
|
@ -10,8 +10,5 @@
|
|||||||
"es": "No se pudó cargar el módulo: {moduleName}",
|
"es": "No se pudó cargar el módulo: {moduleName}",
|
||||||
"na'vi": "Oeru Oel {moduleName}it sung.",
|
"na'vi": "Oeru Oel {moduleName}it sung.",
|
||||||
"cy": "Wedi methu a llwytho modiwl: {moduleName}"
|
"cy": "Wedi methu a llwytho modiwl: {moduleName}"
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"en": "http://{host}:{port}/{path}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user