Skip to content
Browse files

[fix] Fixed plugin files for Nodejitsu JShint compliance.

  • Loading branch information...
1 parent 43fc5d8 commit 9029bf815b86de8b2be05cd36ee00d295c847035 @AvianFlu AvianFlu committed
Showing with 65 additions and 49 deletions.
  1. +1 −1 lib/plugins/beer.js
  2. +22 −19 lib/plugins/config.js
  3. +6 −6 lib/plugins/gh.js
  4. +7 −5 lib/plugins/help.js
  5. +5 −4 lib/plugins/support.js
  6. +24 −14 lib/plugins/twitter.js
View
2 lib/plugins/beer.js
@@ -1,4 +1,4 @@
-/*
+/*
*
* plugins/beer.js - IRC commands for beer listener
*
View
41 lib/plugins/config.js
@@ -1,4 +1,4 @@
-/*
+/*
*
* config.js - commands to configure Kohai on the fly
*
@@ -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) {
@@ -46,7 +47,7 @@ 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});
}
@@ -54,22 +55,24 @@ var config = module.exports = function (name, operation, key, val) {
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 {
@@ -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.'});
}
-}
+};
View
12 lib/plugins/gh.js
@@ -1,4 +1,4 @@
-/*
+/*
*
* plugins/gh.js - IRC commands for GitHub interaction.
*
@@ -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])) {
@@ -47,5 +47,5 @@ gh.gh = function (data, command) {
msg: data.nick + ', https://github.com/' + result[1]
});
}
-}
+};
View
12 lib/plugins/help.js
@@ -1,4 +1,4 @@
-/*
+/*
*
* help.js - kohai's interactive help system.
*
@@ -6,6 +6,10 @@
*
*/
+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) {
@@ -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 });
-}
View
9 lib/plugins/support.js
@@ -1,4 +1,4 @@
-/*
+/*
*
* support.js - send support emails from the IRC.
*
@@ -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);
@@ -26,4 +27,4 @@ var support = module.exports = function (data, command) {
msg: 'Support email sent successfully. Someone will try to find you ASAP!'
});
});
-}
+};
View
38 lib/plugins/twitter.js
@@ -1,4 +1,4 @@
-/*
+/*
*
* plugins/twitter.js - IRC commands for Twitter interaction.
*
@@ -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.
Something went wrong with that request. Please try again.