Skip to content

Commit

Permalink
tweet tweet tweet
Browse files Browse the repository at this point in the history
  • Loading branch information
flores committed Nov 9, 2011
1 parent ede3205 commit b15bc06
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
5 changes: 3 additions & 2 deletions package.json
@@ -1,10 +1,11 @@
{
"name": "snake-eyes",
"description": "A helpfull irc bot and http listener",
"version": "0.0.1",
"version": "0.0.2",
"author": "bosty <github@borderstylo.com>",
"dependencies": {
"irc": ">= 0.3.2"
"irc": ">= 0.3.2",
"twitter": ">= 0.1.17"
},
"engine": "node 0.4.12"
}
Expand Down
50 changes: 38 additions & 12 deletions snake-eyes.js
Expand Up @@ -22,15 +22,12 @@ var opusers_public = [
var botname_private = "snake-eyes";
var server_private = "irc.borderstylo.com";
var channel_private = [
"#clients",
"#clients",
"#ops",
"#shark",
"#pv"
"#pv",
"#mobile"
];

// we make an http server to listen for
// continuous integration hooks from CI Joe.
var http_port = 8124;

// #devlife
var lunchSpots = [
Expand All @@ -50,9 +47,28 @@ var lunchSpots = [
"Explore Fairfax, you cautious bitches."
];

// we make an http server to listen for
// continuous integration hooks from CI Joe.
var http_port = 8124;

// k.
// want the bot to tweet notifications out?
// set this up (move twitter_settings.js.example to twitter_settings.js)
try {
var twitter_settings = require('./twitter_settings');
var sys = require('sys');
var twitter = require('twitter');
var twit = new twitter({
consumer_key: twitter_settings.consumer_key,
consumer_secret: twitter_settings.consumer_secret,
access_token_key: twitter_settings.access_token_key,
access_token_secret: twitter_settings.access_token_secret
});
} catch(e) {
var twit = undefined;
console.log("if you'd like to tweet notifications, please move twitter_settings.js.example to twitter_settings.js");
}

// k.

// set up the irc clients
var irc = new Client(
Expand Down Expand Up @@ -85,7 +101,7 @@ var httpHandler = function (req, res) {
req.on('end', function () { res.writeHead(204); res.end(); });
};

// give it some personality
// give the bot some personality
var eliza = new ElizaBot();
// throw away initial (do I need to do this?)
eliza.getInitial();
Expand Down Expand Up @@ -196,23 +212,33 @@ irc_public.on('join', function(to, nick) {


irc_public.on('message', function (nick, to, text) {
if(( /find a dev/.test( text )) && ( nick != botname_public )) {
if(( /find test/.test( text )) && ( nick != botname_public )) {
// check for work hours
var now = new Date();
var hour = now.getHours();
var day = now.getDay();

var needshelp = nick +" is looking for help on " + channel_public + " at " + server_public ;

if (( hour >= 10 ) && ( hour <= 19 ) && ( day >= 1 ) && ( day <= 5 )) {
irc_public.say( to, nick + ": doing it..." );
irc.say( "#shark", "hey guys. " + nick +" is looking for help on #spire at chat.freenode.net" );
irc.say( "#goaway", "hey guys. " + needshelp );
irc_public.say( to, nick + ": pinged the nerds! if they're not here soon, try emailing support@spire.io" );
}
else {
irc_public.say( to, nick + ": i'm looking for nerds, but they work in California from 10am - 7pm Pacific, so no promises" );
irc.say( "#shark", "hey guys. " + nick +" is looking for help on #spire at chat.freenode.net...");
irc.say( "#shark", nick + " knows it's off hours." );
irc.say( "#goaway", "hey guys. " + needshelp );
irc.say( "#goaway", nick + " knows it's off hours." );
irc_public.say( to, nick + ": if no one shows up soon, you can also email them at support@spire.io" );
}

// tweet it too?
if (twit) {
twit.updateStatus(twitter_settings.prepend_messages + needshelp, function(data) {
console.log(data);
});
}

}
});

Expand Down
6 changes: 6 additions & 0 deletions twitter_settings.js.examples
@@ -0,0 +1,6 @@
this.consumer_key = '';
this.consumer_secret = '';
this.access_token_key = '';
this.access_token_secret = '';
// prepended to twitter updates. use it to notify users and stuff.
this.prepend_messages = '';

0 comments on commit b15bc06

Please sign in to comment.