Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for non case-sensitive ircd's #70

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
config.json
node_modules
1 change: 0 additions & 1 deletion bin/kohai
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node

var Kohai = require('../lib/kohai').Kohai;

var kohai = new Kohai({
Expand Down
105 changes: 61 additions & 44 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,20 @@
"children": [
"irc",
"twitter",
"mailer"
"mailer",
"feedsub"
],
"access": {
"admin": [
"AvianFlu",
"Marak",
"indexzero",
"hij1nx"
"willwh"
],
"employee": [
"SubStack",
"bradleymeck",
"jameson",
"jesusabdullah",
"slickplaid"
"Goune",
"Mifun",
"Anubis",
"Phineus"
],
"friend": [
"isaacs",
"indutny",
"ryah",
"TheJH"
]
"friend": []
},
"ranks": [
"admin",
Expand All @@ -41,26 +33,22 @@
"%% actually looks rather nice today."
],
"help": {
"password": "To reset your password, type `jitsu users forgot [username]`. To change it, type `jitsu users changepassword`.",
"handbook": "The complete Nodejitsu handbook can be read at http://github.com/nodejitsu/handbook",
"support": "If no one is here to help you, type `!support [msg]` to send an email to support@nodejitsu.com.",
"blog": "Our blog can be viewed at http://blog.nodejitsu.com - a number of tutorials can be found there.",
"forever": "Run and monitor your node.js processes forever - http://github.com/indexzero/forever",
"http-proxy": "A robust, full-featured HTTP proxy for Node.js with full websocket support - http://github.com/nodejitsu/node-http-proxy",
"jitsu": "A CLI tool for deploying your apps to the Nodejitsu hosting platform - http://github.com/nodejitsu/jitsu",
"hook.io": "A distributed cross-platform namespaced event system using dnode and EventEmitter2 - http://github.com/hookio/hook.io",
"node-prompt": "An easy-to-use library for getting input from users while your program is running - http://github.com/nodejitsu/node-prompt",
"gh": "Link to GitHub repositories, issues and commits: `!gh [user]`, `!gh [user]/[project]`, `!gh [user]/[project]@[sha]`, `!gh [user]/[project]#[issue]` are supported",
"blog": "http://www.embersofcaerus.com/blog.php",
"forum": "http://www.embersofcaerus.com/forum/forum.php",
"site": "http://www.forsakenstudios.com/",
"like": "Type !like [drink] to select drink you get when you receive karma"
},
"irc-server": "irc.freenode.net",
"irc-server": "irc.stratics.com",
"port": 6667,
"nick": "kohai-default",
"channels": ["#nodebombrange", "#kohai"],
"nick": "forsakenbot",
"password": "3176df2k11&3@%",
"channels": [
"#forsakenstudios"
],
"showErrors": "true",
"userName": "kohai",
"realName": "the lovable IRC bot",
"idCheck": true,
"userName": "ForsakenBot",
"realName": "www.forsakenstudios.com",
"idCheck": false,
"channelDefaults": {
"commandString": "!",
"messageCount": 0,
Expand All @@ -71,26 +59,55 @@
"rate": 0,
"autoVolume": true,
"active": true,
"wantsTweets": true
"wantsTweets": "true",
"wantsRSS": "true"
},
"auth": {
"twitter": {
"consumer_key": "Public key for Streaming API access",
"consumer_secret": "Secret key for Streaming API access",
"access_token_key": "Public key for REST API access",
"access_token_secret": "Secret key for REST API access"
"consumer_key": "A0Rg9zs3fCB7MLbwqFIDYA",
"consumer_secret": "oiifN7jQl5NjAC1qMxxUdfgzMX8u8tIuhdwEtnUBh8",
"access_token_key": "121676942-TOuet5UnHFTIb9qtsEcbeuEnW6gicfRyvazjGdBy",
"access_token_secret": "CuTGNdVTUnN0hHaDJMOK83wzSMNN1oE97t9XNyjq8I"
},
"bitly": {
"user": "nodejitsu",
"key": "R_067ef6cdcfc2b223ea26a986395b420c"
"user": "ilovedf",
"key": "R_1013e8c9107d6c33ee18096f06b77575"
}
},
"track": [
"Node.js",
"Nodejitsu",
"#nodejs",
"NodeKohai"
"forsaken studios",
"embers of caerus",
"@forsakenstudios"
],
"follow": [],
"recentTweets": []
"recentTweets": [
null,
null
],
"feeds": [
{
"name": "emberblog",
"url": "http://www.embersofcaerus.com/external.php",
"interval": 1,
"emitOnStart": false
}
],
"karma": {
"values": {
"willwh": 9128,
"laugh": 1,
"Slash_Redhand": 0,
"DaveB": 10000,
"Yeti": 1,
"forsakenbot": 0,
"Kirst": 1,
"Kristy": 0,
"Wulvgar": 1
},
"preferences": {
"willwh": "elephant",
"Slash_Redhand": "apples",
"[WSX]Thradok": "water"
}
}
}
8 changes: 4 additions & 4 deletions lib/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
var comments = module.exports = function (data) {

switch(true) {
case /\bkohai\b.*\bbot\b.*/i.test(data.text):
case /\bforsakenbot\b.*\bbot\b.*/i.test(data.text):
this.emit('sendMsg', {
dest: data.to,
msg: '\'Bot\' is a derogatory term, and I\'m offended.'
});
break;
case /.*\bkohai:(?:\s|$).*/i.test(data.text):
case /.*\bforsakenbot:(?:\s|$).*/i.test(data.text):
this.emit('sendMsg', {
dest: data.to,
msg: 'I am Kohai, semi-useful communications-facilitating pseudointelligence!'
msg: 'I am forsakenbot, semi-useful MMO communications-facilitating pseudointelligence!'
});
break;
default:
// This is the no-match case, do nothing.
break;
}

}
}
21 changes: 15 additions & 6 deletions lib/kohai.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ Kohai.prototype.gotMessage = function (data) {
var idCheck = this.idCheck ? '\\+' : '',
trigger = new RegExp('^'
+ idCheck
+ this.channels[data.to].commandString
+ this.channels[data.to.toLowerCase()].commandString
+ '\\w+\\s?\\w*.*');
this.channels[data.to].messageCount++;
this.channels[data.to.toLowerCase()].messageCount++;
if (trigger.test(data.text)) {
this.checkAuth(data);
}
Expand Down Expand Up @@ -91,7 +91,7 @@ Kohai.prototype.checkAuth = function (data) {
}
});
});
if (data.to === self.nick) {
if (data.to.toLowerCase() === self.nick) {
return self._dispatchPM(data);
}
return self._dispatcher(data);
Expand All @@ -100,8 +100,8 @@ Kohai.prototype.checkAuth = function (data) {
Kohai.prototype._dispatcher = function (data) {
var self = this,
replace = self.idCheck
? '+' + self.channels[data.to].commandString
: self.channels[data.to].commandString,
? '+' + self.channels[data.to.toLowerCase()].commandString
: self.channels[data.to.toLowerCase()].commandString,
command = data.text.replace(replace, '').split(' ');
if ((command[0] !== 'config')&&(typeof triggers[command[0]] !== 'undefined')) {
triggers[command[0]].call(self, data, command);
Expand All @@ -118,7 +118,7 @@ Kohai.prototype._dispatchPM = function (data) {
triggers[command[0].slice(1)].call(this, data, command);
}
else if (typeof triggers[command[0]] !== 'undefined') {
data.to = data.nick;
data.to = data.nick.toLowerCase();
triggers[command[0]].call(this, data, command);
}
}
Expand All @@ -132,6 +132,7 @@ Kohai.prototype.checkComment = function (data) {
comments.call(this, data);
}


Kohai.prototype.sayTweet = function (data) {
var self = this;
Object.getOwnPropertyNames(self.channels).forEach(function (channel) {
Expand All @@ -144,3 +145,11 @@ Kohai.prototype.sayTweet = function (data) {
});
}

Kohai.prototype.sayRSS = function (data) {
var self = this;
Object.getOwnPropertyNames(self.channels).forEach(function (channel) {
if (self.channels[channel].wantsRSS === 'true') {
self.emit('sendMsg', {dest: channel, msg: data});
}
});
}
15 changes: 15 additions & 0 deletions lib/listeners/feedsub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
*
* listeners/feedsub.js - Event listeners for Hook.io-feedsub.
*
*
* Written by willwh.
*
*/

var feedsub = module.exports = function () {
var self = this;
self.on('feedsub::*::item', function (data) {
self.sayRSS(data.title + ' - ' + data.link);
});
};
44 changes: 44 additions & 0 deletions lib/listeners/pars0r.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var select = require('soupselect').select,
htmlparser = require("htmlparser"),
http = require('http'),
util = require('util');

// fetch some HTML...
var http = require('http');
var host = 'www.us1.darkfallonline.com';
var client = http.createClient(80, host);
var request = client.request('GET', '/news/',{'host': host});

request.on('response', function (response) {
response.setEncoding('utf8');

var body = "";
response.on('data', function (chunk) {
body = body + chunk;
});

response.on('end', function() {

// now we have the whole body, parse it and select the nodes we want...
var handler = new htmlparser.DefaultHandler(function(err, dom) {
if (err) {
util.debug("Error: " + err);
} else {

// soupselect happening here...
var accesslvl = select(dom, 'img');
if(accesslvl.indexOf("players_online" !=-1)) {
util.puts("US1: Online for players");
}
else {
util.puts("US1: Offline for players");
}

}
});

var parser = new htmlparser.Parser(handler);
parser.parseComplete(body);
});
});
request.end();
4 changes: 2 additions & 2 deletions lib/plugins/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var support = module.exports = function (data, command) {
source = ' [' + data.nick + ']';

emailOptions = {
to : 'support@nodejitsu.com',
from : 'kohai@nodejitsu.com',
to : 'admin@ilovedarkfall.com',
from : 'kohai@ilovedarkfall.com',
subject : '[IRC]' + source,
body : new Date() + ' ' + msg
};
Expand Down
5 changes: 3 additions & 2 deletions lib/triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ var triggers = module.exports = {
+ ' has exceeded specified telemetry parameters. Irrevocable '
+ timer + ' second mute has been initiated.'
});
self.emit('command', 'mode ' + dest + ' +q ' + command[1]);
self.emit('command', 'mode' + dest + ' +b ' + command[1]);
console.log('command', 'mode' + dest + ' +b ' + command[1]);
setTimeout(function () {
self.emit('command', 'mode ' + dest + ' -q ' + command[1]);
self.emit('command', 'mode' + dest + ' -b ' + command[1]);
self.emit('sendMsg', {
dest: dest,
msg: 'Noobosity telemetry data now below thresholds. Removing mute for ' + command[1] + '.'
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"colors": "0.5.x",
"hook.io-irc": "0.4.x",
"hook.io-twitter": "0.2.x",
"hook.io-mailer": "0.3.x"
"hook.io-mailer": "0.3.x",
"hook.io-feedsub": "0.1.x"
},
"engines": {
"node": ">= 0.4.x < 0.7.x"
Expand Down