mergy mergy

This commit is contained in:
reality 2013-04-30 13:53:16 +00:00
commit 88c51209af
5 changed files with 108 additions and 35 deletions

View File

@ -72,7 +72,7 @@ var commands = function(dbot) {
event.reply(stdout); event.reply(stdout);
} }
else{ else{
event.reply("No version information or queried module not loaded"); event.reply(dbot.t("no_version"));
} }
}.bind(this)); }.bind(this));
}, },
@ -83,12 +83,12 @@ var commands = function(dbot) {
if(_.has(dbot.status, moduleName)) { if(_.has(dbot.status, moduleName)) {
var status = dbot.status[moduleName]; var status = dbot.status[moduleName];
if(status === true) { if(status === true) {
event.reply(moduleName + ' status: Shit looks good.'); event.reply(dbot.t("status_good",{"module":moduleName, "reason": status}));
} else { } else {
event.reply(moduleName + ' status: Failed to load: ' + status); event.reply(dbot.t("status_bad",{"module":moduleName, "reason": status}));
} }
} else { } else {
event.reply('Either that module wasn\'t on the roster or shit is totally fucked.'); event.reply(dbot.t("status_unloaded"));
} }
}, },
@ -103,7 +103,7 @@ var commands = function(dbot) {
'say': function(event) { 'say': function(event) {
var channel = event.params[1]; var channel = event.params[1];
if(event.params[1] === "@") { if(event.params[1] === "@") {
var channel = event.channel.name; channel = event.channel.name;
} }
var message = event.params.slice(2).join(' '); var message = event.params.slice(2).join(' ');
dbot.say(event.server, channel, message); dbot.say(event.server, channel, message);
@ -118,7 +118,7 @@ var commands = function(dbot) {
if(dbot.status[moduleName] === true) { if(dbot.status[moduleName] === true) {
event.reply(dbot.t('load_module', {'moduleName': moduleName})); event.reply(dbot.t('load_module', {'moduleName': moduleName}));
} else { } else {
event.reply('Failed to load ' + moduleName + '. See \'status ' + moduleName + '\'.'); event.reply(dbot.t("load_failed",{"module": moduleName}));
} }
} else { } else {
if(moduleName == 'web') { if(moduleName == 'web') {
@ -162,6 +162,10 @@ var commands = function(dbot) {
newOption = (newOption == "true"); newOption = (newOption == "true");
} }
if(_.isArray(currentOption)) {
event.reply(dbot.t("config_array",{"alternate": "pushconfig"}));
}
event.reply(configPath + ": " + config + " -> " + newOption); event.reply(configPath + ": " + config + " -> " + newOption);
config = newOption; config = newOption;
this.db.save('config', configPath, { this.db.save('config', configPath, {
@ -171,11 +175,11 @@ var commands = function(dbot) {
dbot.reloadModules(); dbot.reloadModules();
}); });
} else { } else {
event.reply('Config path doesn\'t exist, bro.'); event.reply(dbot.t("no_config_key"));
} }
}.bind(this)); }.bind(this));
} else { } else {
event.reply("This config option cannot be altered while the bot is running."); event.reply(dbot.t("config_lock"));
} }
}, },
@ -196,14 +200,14 @@ var commands = function(dbot) {
dbot.reloadModules(); dbot.reloadModules();
}); });
} else { } else {
event.reply("Config option is not an array. Try 'setconfig'."); event.reply(dbot.t("config_array", { "alternate": "setconfig" }));
} }
} else { } else {
event.reply('Config path doesn\'t exist, bro.'); event.reply(dbot.t("no_config_key"));
} }
}.bind(this)); }.bind(this));
} else { } else {
event.reply("This config option cannot be altered while the bot is running."); event.reply(dbot.t("config_lock"));
} }
}, },
@ -213,18 +217,30 @@ var commands = function(dbot) {
this.internalAPI.getCurrentConfig(configPath, function(config) { this.internalAPI.getCurrentConfig(configPath, function(config) {
if(config !== null) { if(config !== null) {
if(_.isArray(config)) { if(_.isArray(config)) {
event.reply('Config keys in ' + configPath + ': ' + config); event.reply(dbot.t("config_keys_location", {
"path": configPath,
"value": config
}));
} else if(_.isObject(config)) { } else if(_.isObject(config)) {
event.reply('Config keys in ' + configPath + ': ' + _.keys(config)); event.reply(dbot.t("config_keys_location", {
"path": configPath,
"value": _.keys(config)
}));
} else { } else {
event.reply(configPath + ': ' + config); event.reply(dbot.t("config_keys_location", {
"path": configPath,
"value": config
}));
} }
} else { } else {
event.reply('Config path doesn\'t exist, bro.'); event.reply(dbot.t("no_config_key"));
} }
}); });
} else { } else {
event.reply('Config keys in root: ' + _.keys(dbot.config)); event.reply(dbot.t("config_keys_location", {
"path": "root",
"value": _.keys(dbot.config)
}));
} }
} }
}; };

View File

@ -95,5 +95,35 @@
"en": "{moduleName} is already loaded.", "en": "{moduleName} is already loaded.",
"na'vi": "Oel omum teri {moduleName}it li.", "na'vi": "Oel omum teri {moduleName}it li.",
"nl": "{moduleName} is al geladen." "nl": "{moduleName} is al geladen."
},
"no_version": {
"en": "No version information or queried module not loaded."
},
"status_good": {
"en": "{module} status: Shit looks good"
},
"status_bad": {
"en": "{module} status: Failed to load: {reason}"
},
"status_unloaded": {
"en": "Either thata module wasn't on the roster or shit is totally fucked."
},
"load_failed": {
"en": "Failed to load {module}. See 'status {module}'."
},
"no_config_key": {
"en": "Config key doesn't exist bro"
},
"config_array": {
"en": "Config option is an array. Try '{alternate}'."
},
"config_lock": {
"en": "This config option cannot be altered while the bot is running."
},
"no_config_path": {
"en": "Config path doesn't exist bro"
},
"config_keys_location": {
"en": "Config keys in {path}: {value}"
} }
} }

View File

@ -30,7 +30,7 @@ var pages = function(dbot) {
/* TODO: merge back into github module */ /* TODO: merge back into github module */
var milestones; var milestones;
request("https://api.github.com/repos/" + dbot.config.github.defaultrepo + "/milestones?state=open", function(error, response, body){ request({"url":"https://api.github.com/repos/" + dbot.config.github.defaultrepo + "/milestones?state=open","headers":{"User-Agent":"reality/depressionbot (project module)"}}, function(error, response, body){
milestones = JSON.parse(body); milestones = JSON.parse(body);
}); });

View File

@ -5,8 +5,7 @@ Track users.
### Description ### Description
This module tracks users and their aliases through nick changes and all that This module tracks users and their aliases through nick changes and all that
kind of thing. It's mainly a utility module for other modules to use. It's kind of thing. It's mainly a utility module for other modules to use.
also totally !insaned.
### Commands ### Commands
@ -27,25 +26,51 @@ Requires moderator level access by default.
### API ### API
#### resolveUser(server, nick, [useLowerCase]) #### resolveUser(server, nick, callback)
This resolves a given nick to its primary user and returns it. This resolves a given nick to its primary user, returning false if no user
record is found in the store associated with the given nickname (either as a
primary nick or an alias). The callback is called with one argument, a _user_
object or false if no user was found.
Note that if the useLowerCase argument is set to true, it will do a lower-case #### getUser(uuid, callback)
search, however it will return the username in its properly capitalised form, so Get a user by its uuid. Callback is called with one argument, a _user_ object or
remember to lower case the return value if you are using lower case values as false if no user was found by that uuid.
keys.
#### resolveUser(server, user) #### getChannel(server, channelName, callback)
Return whether a user is known either as an alias or a primary user. This resolves a given server and channel name to a particular channel. The
callback is called with one argument, a _channel_ object or false if no channel
was found with the given name on the given server.
#### isPrimaryUser(server, nick) #### getRandomChannelUser(server, channel, callback)
Return whether a nick is known as a primary user. Given a server name and a channel name, this gets a random user from that
channel. Callback is called with one argument, a _user_ object or false if no
channel was found from the given parameters.
#### getAliases(server, user) #### getAllusers(callback)
Return a list of aliases for a given primary user. Get a list of all users the bot currently knows about. Callback is called with
one argument, a list of user records.
#### isOnline(server, user, channel, useLowerCase) ### Data
Return whether a user is online in a given channel on the given server.
#### User Object
{
id: user uuid,
primaryNick,
currentNick: Current or last used nickname,
server,
channels: A list of names for channels this user has been in,
aliases: A list of known aliases for this user
}
#### Channel Object
{
id: channel uuid,
server,
name,
users: A list of the uuids of users who are in this channel
}
### Events ### Events

View File

@ -1,15 +1,17 @@
WebFontConfig={google:{families:["Ubuntu+Mono::latin","Ubuntu::latin"]}};(function(){var e=document.createElement("script");e.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";e.type="text/javascript";e.async="true";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})()
$(document).ready(function() { $(document).ready(function() {
$.get("https://api.github.com/repos/#{repo}/pulls", function(data) { $.get("https://api.github.com/repos/#{repo}/pulls", function(data) {
if ($.parseJSON(data).length) { $("#pullreq").show();} if ($.parseJSON(data).length) { $("#pullreq").show();}
}); });
}); });
$(document).keypress(function(e) { $(document).keypress(function(e) {
WebFontConfig={google:{families:["Ubuntu::latin"]}};(function(){var e=document.createElement("script");e.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";e.type="text/javascript";e.async="true";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})()
$('body').css({ $('body').css({
"background-image":"url('http://i.imgur.com/Yh8V2Oa.jpg')", "background-image":"url('http://i.imgur.com/Yh8V2Oa.jpg')",
"font-family": "Ubuntu, \"Source Sans Pro\",sans-serif" "font-family": "Ubuntu, \"Source Sans Pro\",sans-serif"
}); });
$('pre').css("font-family","Ubuntu Mono");
$('a').css("color","#DD4814"); $('a').css("color","#DD4814");
$('#title').css("color","white"); $('#title').css("color","white");
$('#main').css("border-color","#420432"); $('.progress-inner').css("background-image","linear-gradient(to top, rgb(211, 72, 20), rgb(255, 180, 127))");
// $('#main').css("color","#420432");
}); });