Created
December 30, 2012 23:39
-
-
Save flexd/4416043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var irc = require('irc'); | |
var express = require('express'); | |
var app = express.createServer(); | |
var net = require('net'); | |
COMMAND_PREFIX="!"; | |
admins = ['flexd', 'DikkeDikke', 'Rolsen']; | |
//var ts = net.connect({host: "hobby.host1.no", port: 10011}); | |
//ts.on('data', function(data) { | |
// console.log(data.toString()); | |
//}); | |
//ts.on('end', function() { | |
// console.log('ts disconnected'); | |
//}); | |
// | |
// | |
var irc = new irc.Client('irc.efnet.org', 'zombiebot', { | |
channels: ['#nff.dayz'], | |
}); | |
console.log("Kobler til server..."); | |
var thetopic = ""; | |
irc.addListener('message', function (from, to, message) { | |
console.log(from + ' => ' + to + ': ' + message); | |
if ( to.match(/^[#&]/) ) { | |
var temp = message.split(' '); | |
var prefix = temp.splice(0, 1)[0]; | |
var command; | |
if (prefix === irc.nick + ':') { | |
command = temp.splice(0, 1)[0]; | |
} | |
else { | |
command = prefix.slice(1); | |
} | |
var args = temp.join(' '); | |
console.log('temp is: ' + temp); | |
console.log('prefix is: ' + prefix); | |
console.log('command is: ' + command); | |
console.log('args is: ' + args); | |
if (command) { | |
// channel message | |
if (command.match(/^topic$/i) ) { | |
irc.send('TOPIC', to, args); | |
thetopic = args; | |
} | |
if (command.match(/^server-info$/)) { | |
irc.say(to, thetopic); | |
}; | |
if (command.match(/^dance$/) ) { | |
setTimeout(function () { irc.say(to, "\u0001ACTION dances: :D\\-<\u0001") }, 500); | |
setTimeout(function () { irc.say(to, "\u0001ACTION dances: :D|-<\u0001") }, 700); | |
setTimeout(function () { irc.say(to, "\u0001ACTION dances: :D/-<\u0001") }, 900); | |
setTimeout(function () { irc.say(to, "\u0001ACTION dances: :D|-<\u0001") }, 1100); | |
} | |
} | |
} | |
else { | |
// private message | |
} | |
}); | |
irc.addListener('join#nff.dayz', function (nick ,message) { | |
if (admins.indexOf(nick) >= 0) { | |
console.log("Opping admin"); | |
irc.send('MODE', '#nff.dayz', '+o', nick); | |
} | |
}); | |
irc.addListener('topic', function (channel, topic, nick, message) { | |
// console.log(channel + ' : ' + nick + ' : ' + topic + ': ' + message); | |
thetopic = topic; | |
}); | |
app.get('/', function(req, res){ | |
res.send(thetopic); | |
}); | |
irc.addListener('error', function(message) { | |
console.log('error: ', message); | |
}); | |
app.listen(7000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment