Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 36 additions and 5 deletions.
  1. +18 −2 api.js
  2. +16 −3 standup-irc.js
  3. +2 −0  utils.js
20 api.js
View
@@ -1,4 +1,6 @@
/* Functions to access the remote web api of a standup app. */
+var _ = require('underscore');
+
var utils = require('./utils');
exports.status = {
@@ -32,5 +34,19 @@ exports.status = {
}
};
-function submitStatus(irc_handle, irc_channel, content) {
-}
+exports.user = {
+ /* Change a user's values
+ * - `target_user` - The user to modify.
+ * - `acting_user` - The user making the changes.
+ * - `changes` - An object describing the changes to be made. For example,
+ * to change the email of a user, this would be {email: 'bob@example.com'}
+ */
+ update: function(target_user, acting_user, changes) {
+ var data = {
+ api_key: CONFIG.standup.api_key,
+ user: acting_user
+ };
+ _.extend(data, changes);
+ return utils.request('/api/v1/user/' + target_user + '/', 'POST', data);
+ }
+};
19 standup-irc.js
View
@@ -132,7 +132,7 @@ client.on('message', function(user, channel, msg) {
client.on('notice', function(from, to, text) {
if (from === undefined) {
- console.log('Service Notice: ' + text);
+ logger.info('Server Notice: ' + text);
from = '';
}
from = from.toLowerCase();
@@ -173,8 +173,8 @@ var commands = {
});
ret.once('error', function(code, data) {
if (code === 403) {
- client.say(channel, "You don't have permissiont to do that. " +
- "Do you own that status?");
+ client.say(channel, "You don't have permissiont to do " +
+ "that. Do you own that status?");
} else {
client.say(channel, "I'm a failure, I couldn't do it.");
}
@@ -182,6 +182,19 @@ var commands = {
});
},
+ /* Modify a user. */
+ 'user': function(user, channel, message, args) {
+ utils.ifAuthorized(user, channel, function() {
+ var target = args[0];
+ var changes = {};
+ _.each(args.slice(1), function(arg) {
+ var match = /([^=]+)=(.+)/.exec(arg);
+ changes[match[1]] = match[2];
+ });
+ var ret = api.user.update(args[0], user, changes);
+ });
+ },
+
/* Every bot loves botsnacks. */
'botsnack': function(user, channel, message, args) {
var responses = [
2  utils.js
View
@@ -37,6 +37,8 @@ function request(path, method, data, emitter) {
} else if (res.statusCode === 301) {
request(res.headers.location, method, data, emitter);
} else {
+ logger.error(options.path + ': ' + res.statusCode + ' ' +
+ resp_data);
emitter.emit('error', res.statusCode, resp_data);
}
});

No commit comments for this range

Something went wrong with that request. Please try again.