Skip to content

Commit

Permalink
[fix] Fixed plugin files for Nodejitsu JShint compliance.
Browse files Browse the repository at this point in the history
  • Loading branch information
AvianFlu committed Oct 28, 2011
1 parent 43fc5d8 commit 9029bf8
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 49 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/beer.js
@@ -1,4 +1,4 @@
/*
/*
*
* plugins/beer.js - IRC commands for beer listener
*
Expand Down
41 changes: 22 additions & 19 deletions lib/plugins/config.js
@@ -1,4 +1,4 @@
/*
/*
*
* config.js - commands to configure Kohai on the fly
*
Expand All @@ -10,33 +10,34 @@ var config = module.exports = function (name, operation, key, val) {
// Permissions already checked, so no need here.
// Thanks again to samsonjs for the config code.

var self = this;
var self = this,
repr,
a, b;

// get key
if (operation === 'get') {
if (!key) {
self.emit('sendMsg', {dest: name, msg: 'Get what?'});
if (!key) {
self.emit('sendMsg', {dest: name, msg: 'Get what?'});
}
else if (!key.match(/^auth.*/)) {
var repr;
else if (!key.match(/^auth[:\w\d\s]*/)) {
val = self.config.get(key);
if (val && typeof val.join === 'function') {
repr = '[' + val.join(', ') + ']'
repr = '[' + val.join(', ') + ']';
}
else {
repr = JSON.stringify(val)
repr = JSON.stringify(val);
}
self.emit('sendMsg', {dest: name, msg: key + ' is ' + repr});
}
else {
self.emit('sendMsg', {dest: name, msg: 'Retrieval of authorization info not permitted.'});
else {
self.emit('sendMsg', {dest: name, msg: 'Retrieval of authorization info not permitted.'});
}
}

// set key json
else if (operation === 'set') {
try {
self.config.set(key, JSON.parse(val))
self.config.set(key, JSON.parse(val));
self.emit('sendMsg', {dest: name, msg: key + ' has been set to: ' + val + '.'});
}
catch (e) {
Expand All @@ -46,30 +47,32 @@ var config = module.exports = function (name, operation, key, val) {

// add list-key value
else if (operation === 'add') {
var a = self.config.get(key);
a = self.config.get(key);
if (!(a && typeof a.push === 'function')) {
self.emit('sendMsg', {dest: name, msg: 'Sorry, cannot add to ' + key});
}
else if (a.indexOf(val) !== -1) {
self.emit('sendMsg', {dest: name, msg: val + ' is already in ' + key});
}
else {
a.push(val)
self.config.set(key, a)
a.push(val);
self.config.set(key, a);
self.emit('sendMsg', {dest: name, msg: val + ' was added to ' + key + '.'});
}
}

// rm list-key value
else if (operation === 'rm') {
var a = self.config.get(key)
a = self.config.get(key);
if (!(a && typeof a.filter === 'function')) {
self.emit('sendMsg', {dest: name, msg: 'Sorry, cannot remove from ' + key});
return
return;
}
var b = a.filter(function(x) { return x !== val })
b = a.filter(function (x) {
return x !== val;
});
if (b.length < a.length) {
self.config.set(key, b)
self.config.set(key, b);
self.emit('sendMsg', {dest: name, msg: val + ' was removed from ' + key + '.'});
}
else {
Expand All @@ -91,4 +94,4 @@ var config = module.exports = function (name, operation, key, val) {
else {
self.emit('sendMsg', {dest: name, msg: 'Sorry, ' + name + ', invalid operation for config.'});
}
}
};
12 changes: 6 additions & 6 deletions lib/plugins/gh.js
@@ -1,4 +1,4 @@
/*
/*
*
* plugins/gh.js - IRC commands for GitHub interaction.
*
Expand All @@ -12,10 +12,10 @@ gh.gh = function (data, command) {
if (!command[1]) {
return;
}
var user = /([\w\.-]+)/,
project = /([\w\.-]+)\/([\w\.-]+)/,
issue = /([\w\.-]+)\/([\w\.-]+)#(\d+)/,
SHA = /([\w\.-]+)\/([\w\.-]+)@([a-fA-F0-9]+)/,
var user = /([\w\.\-]+)/,
project = /([\w\.\-]+)\/([\w\.\-]+)/,
issue = /([\w\.\-]+)\/([\w\.\-]+)#(\d+)/,
SHA = /([\w\.\-]+)\/([\w\.\-]+)@([a-fA-F0-9]+)/,
result;

if (result = issue.exec(command[1])) {
Expand Down Expand Up @@ -47,5 +47,5 @@ gh.gh = function (data, command) {
msg: data.nick + ', https://github.com/' + result[1]
});
}
}
};

12 changes: 7 additions & 5 deletions lib/plugins/help.js
@@ -1,11 +1,15 @@
/*
/*
*
* help.js - kohai's interactive help system.
*
* (c) 2011 Nodejitsu Inc.
*
*/

function say(dest, msg) {
this.emit('sendMsg', { dest: dest, msg: msg });
}

var help = module.exports = function (data, command) {
var helpInfo = this.config.get('help');
if (command.length === 1) {
Expand All @@ -20,8 +24,6 @@ var help = module.exports = function (data, command) {
else if (command[1] === 'list') {
say.call(this, data.nick, 'Available help topics: ' + Object.keys(helpInfo).join(' '));
}
}
};


function say(dest, msg) {
this.emit('sendMsg', { dest: dest, msg: msg });
}
9 changes: 5 additions & 4 deletions lib/plugins/support.js
@@ -1,4 +1,4 @@
/*
/*
*
* support.js - send support emails from the IRC.
*
Expand All @@ -8,14 +8,15 @@

var support = module.exports = function (data, command) {
var self = this,
emailOptions,
msg = command.slice(1).join(' '),
source = ' [' + data.nick + ']';

var emailOptions = {
emailOptions = {
to : 'support@nodejitsu.com',
from : 'kohai@nodejitsu.com',
subject : '[IRC]' + source,
body : new Date + ' ' + msg
body : new Date() + ' ' + msg
};

self.emit('sendEmail', emailOptions);
Expand All @@ -26,4 +27,4 @@ var support = module.exports = function (data, command) {
msg: 'Support email sent successfully. Someone will try to find you ASAP!'
});
});
}
};
38 changes: 24 additions & 14 deletions lib/plugins/twitter.js
@@ -1,4 +1,4 @@
/*
/*
*
* plugins/twitter.js - IRC commands for Twitter interaction.
*
Expand All @@ -9,36 +9,46 @@
var twitter = exports;

twitter.tweet = function (data, command) {
if (!data[this.ranks[2]]) { return false; }
if (!data[this.ranks[2]]) {
return false;
}
var text = command.slice(1).join(' ');
if (text.length > 140) {
this.emit('sendMsg', {
dest: data.to,
msg: 'Sorry ' + data.nick + ', that tweet message exceeds 140 characters (' + text.length + ').'
this.emit('sendMsg', {
dest: data.to,
msg: 'Sorry ' + data.nick + ', that tweet message exceeds 140 characters (' + text.length + ').'
});
}
this.emit('tweet', text);
}
};

twitter.stoptweets = function (data, command) {
if (!data[this.ranks[1]]) {return false; }
if (!data[this.ranks[1]]) {
return false;
}
this.emit('stopTweets', null);
}
};

twitter.starttweets = function (data, command) {
if (!data[this.ranks[1]]) { return false; }
if (!data[this.ranks[1]]) {
return false;
}
this.emit('startTweets', null);
}
};

twitter.report = function (data, command) {
if (!data[this.ranks[1]]) { return false; }
if (!data[this.ranks[1]]) {
return false;
}
this.emit('report', {name: command[1], to: data.to});
}
};

twitter.block = function (data, command) {
if (!data[this.ranks[1]]) { return false; }
if (!data[this.ranks[1]]) {
return false;
}
this.emit('block', {name: command[1], to: data.to});
}
};



0 comments on commit 9029bf8

Please sign in to comment.