Skip to content

Instantly share code, notes, and snippets.

@io4
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save io4/e8577061a79e805893fb to your computer and use it in GitHub Desktop.
Save io4/e8577061a79e805893fb to your computer and use it in GitHub Desktop.
Node.js Farmerbot

To use it: Run "npm install node-irc" Set owner to your nick. Do "node bot.js" Wait for it to collect monney!

var ircClient = require('node-irc');
var server = 'irc.freenode.net',
port = 6667,
nick = 'IoTheFarmBot',
fullname = 'Io bot 4',
chan = '##powder-moo';
owner = 'iovoid';
// Create client object, pass in constructor arguments
var client = new ircClient(server, port, nick, fullname);
// This decides the verbosity of the output, set to 1 as default
client.verbosity = 2; // 0 == Silent, 1 == Normal, 2 == Info
// This is set to false by defaults, prints out all raw server messages
client.debug = true;
function startFarm(){
timer1 = setInterval(function () {
client.say(chan, "./bc24");
}, 30000);
timer2 = setInterval(function () {
client.say(chan, "./use cow");
}, 3000);
timer3 = setInterval(function () {
client.say(chan, "./sellall");
}, 60000);
timer4 = setInterval(function () {
client.say(chan, "./give "+owner+" <<calc $cash-400000000>>");
}, 600000);
}
function stopFarm(){
console.log("Stopped farming.");
clearInterval(timer1);
clearInterval(timer2);
clearInterval(timer3);
clearInterval(timer4);
client.say(chan, "Stopped farming.");
}
// Key piece.
client.on('ready', function () {
client.join(chan);
setTimeout(function () {
startFarm();
}, 6000);
});
/** \**
* *
* THESE ARE THE AVAILABLE EVENT TRIGGERS *
* *
**\ **/
client.on('CHANMSG', function (data) {
/**
The data object contains
data.receiver : The channel the message was written in prefixed with hash (#)
data.sender : The nick of the person who sent the message
data.message : The message the person sent
**/
var message = data.sender + ' said: ' + data.message;
var msg=data.message;
console.log(msg);
if(data.sender !== nick){
if(msg.charAt(0)=="?" && msg.charAt(1)=="!"){
var cmd=msg.substr(2);
if(cmd=="ping"){client.say(data.receiver, "PONG!");}
if(cmd=="start" && data.sender==owner){startFarm();}
if(cmd=="stop" && data.sender==owner){stopFarm();}
if(cmd=="cashout" && data.sender==owner){client.say(data.receiver, "./give "+owner+" <<calc $cash-400000000>>");}
//client.say(data.receiver, message);
}
}
});
client.on('PRIVMSG', function (data) {});
client.on('JOIN', function (data) {});
client.on('INVITE', function (data) {});
client.on('TOPIC', function (data) {});
client.on('PART', function (data) {});
client.on('KICK', function (data) {
if(data.message[0]==nick){
/**
The data object contains:
data.receiver : The channel the person got kicked out of, prefixed by a hash (#)
data.sender : The nick of the person who kicked out the other person
data.message[0] : The nick of the person who got kicked out
data.message[1] : The optional kick message, will default to the nick of the kicked user
**/
client.join(data.receiver);
}
});
client.on('QUIT', function (data) {});
client.on('NICK', function (data) {});
process.stdin.resume();
process.stdin.setEncoding('utf8');
var chants = '##powder-moo'
process.stdin.on('data', function (data) {
//console.log(data.toString().trim());
var util= require('util');
var dstr=data.toString().trim();
client.say(chants, dstr);
});
client.connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment