nick: 'contributor-helper',
    dev: false
}).argv().env();

var config = nconf.get();

var ircChannels = require('./irc_channels.json');
if ( config.dev ) {
  ircChannels = require('./irc_channels_dev.json');
}


var ircClient = new IRC.Client('irc.mozilla.org', config.nick, {
    secure: true,
    port: 6697,
    userName: config.nick,
    realName: 'The friendly contributor helper',
    channels: Object.keys(ircChannels)
});


var bzClient = bz.createClient({
    url: 'https://api-dev.bugzilla.mozilla.org/latest/'
});


function fetchBugs(channel, product, component) {
    var searchTerms = {'status_whiteboard': 'mentor',
                       'whiteboard_type': 'contains_all',
                       'product': product,
                       'component': component,
Example #2
0
	(watchs[nick] || []).forEach(function (watcher, i) {
		client.say(watcher, nick + ' said : ' + message);
	});
Example #3
0
#!/bin/env node

var irc = require('irc');
var botName = 'dopefish';
var master = 'joo';

var bot = new irc.Client('irc.synyx.de', botName, {
    channels: ['#dopefish', '#fumarer'],
    port: 6668,
    userName: '******',
    realName: 'dope as fish dude!'
});

bot.addListener('error', function (message) {
    console.log('error: ', message);
});

bot.addListener('invite', function (channel, nick, message) {

    console.log('received invite from ' + nick + ' into ' + channel);

    if (nick === master) {
        bot.join(channel, function () {
            console.log('joined ' + channel);
            bot.say(channel, "servus!");
        });
    } else {
        bot.say(nick, 'nein, nein, nein');
        bot.say(nick, 'im channel ' + channel + ' sind nur langweiler!');
    }
});
			setTimeout(function(){
				Twitch.say("#twitchplayspokemon", "!balance");
			}, ( Math.random()*5000 + 5000 ));
Example #5
0
	(dest & IRC_DEST_CHAN) && messages.forEach(function (msg, i) {
		client.say(MAIN_CHANNEL, logMessage(IRC_EVENT_MSG | IRC_EVENT_BOT,
			[BOT_NAME, (i === 0 && !(dest & IRC_DEST_SILENT) ? nick + ': ' : '')
			+ msg]));
	});
	(dest & IRC_DEST_NICK) && messages.forEach(function (msg) {
		client.say(nick, msg);
	});
}

// Starting IRC client
var client = new irc.Client(IRC_SRV, BOT_NAME, {
	realName: BOT_REAL_NAME,
	port: IRC_PORT,
	autoRejoin: true,
	autoConnect: false,
	debug: true,
	showErrors: true,
	floodProtection: true,
	floodProtectionDelay: 2000
});

// Connecting to IRC
client.connect(Infinity, function () {
	client.join(MAIN_CHANNEL);
});

// Listening for messages
var botRegExp = new RegExp(BOT_NAME + '([ ,:]+)');
client.addListener('message' + MAIN_CHANNEL, function (nick, message) {
	// Logging message
	logMessage(IRC_EVENT_MSG, [nick, message]);
Example #6
0
client.addListener('kick', function(channel, who, by, reason) {
  if(who && !_.include(ignore_nicknames,who))
    client.say(channel, who + ' NO RAGE PLX !!!');
  console.log('%s was kicked from %s by %s: %s', who, channel, by, reason);
});
Example #7
0
const login = require('facebook-chat-api')
const irc = require('irc')
const config = require('./config')

const client = new irc.Client(config.irc.hostname, config.irc.nick, {
	port: config.irc.port,
	secure: config.irc.secure,
	selfSigned: true,
	certExpired: true,
	channels: [config.irc.channel],
	realName: config.irc.nick,
	userName: config.irc.nick,
	debug: true,
})

client.on('registered', () => console.log('Connected to IRC'))

client.on('motd', (motd) => console.log(motd))

client.on('error', (err) => console.error(err))

let facebookUsers = {}

login({
	email: config.facebook.email,
	password: config.facebook.password
}, (err, api) => {
	if (err) return console.error(err)

	console.log('Connected to Facebook')
Example #8
0
var irc = require("irc");
var repl = require("repl");
var fs = require("fs");
var clc = require("cli-color");
var util = require("util");

var config = JSON.parse(fs.readFileSync("config.json"));
var defcfg = {
	autoRejoin: false,
	channels: [],
	messageSplit: 300,
};
config.__proto__ = defcfg;

var bot = new irc.Client(config.server, config.nick, config);
bot.out = {};
bot.out.file = fs.createWriteStream("./data/simbot.log", {flags: 'a'});

bot.conn.setTimeout(180 * 1000);
bot.out.time = function() {
	return new Date().toISOString();
};

bot.out.wrapper = function(type, color, module, message) {
	if (!(typeof(message) === "string" || message instanceof String))
		message = util.inspect(message, {colors: true});
	console.log(clc.blackBright(bot.out.time()) + " " + color("[" + type + ":") + color.bold(module) + color("] ") + message);
	bot.out.file.write(bot.out.time() + " [" + type + ":" + module + "] " + message + "\n", 'utf8');
};

bot.out.log = function(module, message) {
Example #9
0
bot.on("registered", function(message) {
	bot.send("UMODE2", "+B");
	bot.out.ok("irc", "registered on server");
});
Example #10
0
poptart.addListener('message', function(from, to, message) {
  var now = new Date().toJSON();
  db.messages.save({nick: from, message: message, date: now}, function(err, saved) {
    if (err) {
      console.log(err);
    }
  });
  var url = findUrl(message);
  var ytId = parseYoutubeUrl(message);
  if (ytId) {
    currentchan = to;
    youtube.video(ytId, parseYoutubeInfo);
  }
  else if (typeof url != 'undefined' && !silent) {
    parsePageInfo(url, to);    
  }
  if (message.match(/\.\bhelp\b/) ) {
    if (!silent) {
      poptart.say(to, "Use .lastsaw NICK to check when NICK last sent a message. Paste a YouTube URL and I will post info about the title, likes, views and duration. Paste a URL and I will tell you about the page title.");
    }
    else {
      poptart.say(to, "Oops, I've been silenced! I'm a silent logger. Use .lastsaw NICK to check when NICK last sent a message.");
    }
  }
  if (message.match(/\.\bsilent\b/)) {
    silent = 1;
    poptart.say(to, "I'm quiet.");
  }
  if (message.match(/\.\bspeak\b/)) {
    silent = 0;
    poptart.say(to, "I'll speak more now :-)");
  }
  if (message.match(/\.\blastsaw \b/) ) {
    message = message.replace(".lastsaw ", "");
    message = message.replace(/ /g, "");
    if (message !== "poptart") {
      db.messages.find({nick: message}).sort({_id:-1}).limit(1, function(err, messages) {
        if (typeof messages[0] != 'undefined') {
          var date = new Date(messages[0].date);
          var diff = new Date() - date;
          var seconds = Math.round(diff / 1000);
          var minutes = Math.round(seconds / 60);
          var hours = Math.round(minutes / 60);
          var days = Math.round(hours / 24);
          if (seconds >= 60) {
            if (minutes >= 60) {
              if (hours >= 24) {
                poptart.say(to, messages[0].nick + " was last seen " + days + " days ago saying " + messages[0].message);
              }
              else {
                poptart.say(to, messages[0].nick + " was last seen " + hours + " hours ago saying " + messages[0].message);
              }
            }
            else {
              poptart.say(to, messages[0].nick + " was last seen " + minutes + " minutes ago saying " + messages[0].message);
            }
          }
          else {
            poptart.say(to, messages[0].nick + " was last seen " + seconds + " seconds ago saying " + messages[0].message);
          }
        }
        else {
          poptart.say(to, message + " was not found in my logs :o");
        }
      });
    }
    else {
      poptart.say(to, "You can't look for a poptart ;n;");
    }    
  }
});
Example #11
0
  couchdb = require('felix-couchdb'),
  client = couchdb.createClient(5984, 'localhost', "couchpotato", "what,isWhat101"),
  db = client.db('chiglug');

/**
 * finds a link inside a message
 */
var linksfinder = function(message){
	var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;	
	return message.match(exp);
};
var channel = "#chiglug",
    botname = "human";

var client = new irc.Client('irc.oftc.net', 'human', {
    channels: [channel],
});

function process(from, message) {
	var words = message.split(" "),
		property = words[1];

	if(words.length < 3)
		return;
	
	// get rid of the first two elements
	words.splice(0,1);
	words.splice(0,1);
	var value = words.join(" ");

	// get the doc if it exists
Example #12
0
function parseYoutubeInfo(err, data) {
  if( err instanceof Error ) {
  } else {
    poptart.say(currentchan, "Title: " + data.title + " | Likes: " + data.likeCount + " | Views: " + data.viewCount + " | Duration: " + Math.round(data.duration / 60) + " minutes");
  }
}
Example #13
0
File: exah.js Project: disjukr/exah
var fs = require('fs');
var cson = require('cursive');
var irc = require('irc');
var exec = require('child_process').exec;

var template = fs.readFileSync('./template.hx', {encoding: 'utf8'});
var config = cson.parse(fs.readFileSync('./config.cson', {encoding: 'utf8'}));

var client = new irc.Client(config.server, config.nick, {
    port: config.port,
    secure: config.secure,
    autoRejoin: config.autoRejoin,
    autoConnect: config.autoConnect,
    channels: config.channels
});

if (!config.autoConnect)
    client.connect();

client.addListener('error', function(info) {
    console.log('error:', info);
});

client.addListener('message#', function (from, to, message) {
    if (checkCallMe(message)) {
        code = message.substr(client.nick.length + 1);
        runHaxe(code, to);
    }
});

function checkCallMe(message) {
ircClient.on('message', function(user, channel, message) {
    if (message === '!bug') {
        ircClient.say(channel, 'Looking for bugs...');
        fetchBugs(channel, ircChannels[channel].product, ircChannels[channel].component);
    }
});
Example #15
0
client.addListener('join', function(channel, who) {
  if(who && !_.include(ignore_nicknames,who))
    client.say(channel, 'Hello ' + who + ' !');
  console.log('%s has joined %s', who, channel);
});
Example #16
0
client.connect(1, function () {
  client.say(program.channel, program.args[0]);
  client.disconnect();
  process.exit();
});
Example #17
0
client.addListener('part', function(channel, who, reason) {
  if(who && !_.include(ignore_nicknames,who))
    client.say(channel, 'Bye ' + who + ' !');
  console.log('%s has left %s: %s', who, channel, reason);
});
Example #18
0
#!/usr/bin/env node

var irc = require('irc');
var moment = require('moment');
var mongoose = require('mongoose');
var models = require('./models')(mongoose);
var setup = require('./config');

console.log(setup.config);

var bot = new irc.Client(setup.config.server, setup.config.botName, {
    debug: true,
    port:6667,
    secure:true,
    password: setup.config.password,
    channels: setup.config.channels,
});

var dbShared;

var timers = {};

bot.addListener('registered', function(msg){
  //bot connected - setup the mongo connection
  console.log('Connected... setting up mongo connection...');

  mongoose.connect('mongodb://localhost/test');
  
  db = mongoose.connection;
  db.on('error', console.error.bind(console, 'connection error:'));
  db.once('open', function callback () {
Example #19
0
client.addListener('invite', function(channel, from, message) {
  client.join(channel);
  console.log(from + ' invite me to join '+channel);
});
Example #20
0
 timers[from].save(function(err,obj){
   bot.say(to, from + ' your timer stopped. You worked ' + moment.duration(timers[from].duration).humanize());
   //nuke it from the active set
   delete timers[from];
 });
var User = {
	username: 	"******",
	oauth: 		"oauth:iazmm085g57yiy8m5bnswyxdfvjidt7",
	balance: 	NaN,
	wins: 		0,
	losses:		0
}

var Twitch = new irc.Client("irc.twitch.tv", User.username, {
    channels: [["#twitchplayspokemon"] + " " + User.oauth],
    port: 6667,
    debug: false,
    password: User.oauth,
    userName: User.username,
    realName: User.username,
    secure: false,
    showErrors: true,
	floodProtection: true,
	floodProtectionDelay: 500,
	state: {
		acceptingBalanceInquiries: false
	}
});

Twitch.addListener('message', function (from, to, message) {
	if( from == "tppinfobot" ){
		console.log(from + " " + message);
		if( message.contains("new match") ){
			setTimeout(function(){
				Twitch.say("#twitchplayspokemon", "!balance");
			}, ( Math.random()*5000 + 5000 ));
Example #22
0
const irc = require('irc');
const c = require('../');

let channel = '#colortest';
let client = new irc.Client('irc.uk.mibbit.net', 'colorbot1234', {
  channels: [channel]
});

client.on('message' + channel, (from, message) => {
  client.say(channel, 'underline: ' + c.underline(message));
  client.say(channel, 'bold:      ' + c.bold(message));
  client.say(channel, 'italic:    ' + c.italic(message));
  client.say(channel, 'red:       ' + c.red(message));
  client.say(channel, 'rainbow:   ' + c.rainbow(message));
});

/* 
	mainLoop
		Run by an interval, checks for current bot state and if bot is busy.
		Based on state, will call several other functions to perform bot tasks.
		Interval calls can overlap, busy flag makes sure one instance at a time at nice interval.
		Use of interval prevents possability of stack overflow, since mainLoop will not call itself.
*/
function mainLoop(){

    var debugging = process.argv[4] == "-d";

	if( Bot.busy ){
		debug("Bot busy, skipping mainLoop");
		return;
	}

	Bot.busy = true;

	if( Bot.state == "initial_balance" ){
		Twitch.say("#twitchplayspokemon", "!balance");
		debug("Waiting for intial User.balance... (requires certain time window)");
		var balanceUpdateInterval = setInterval(function(){
			debug("Inside interval");
			if( ! isNaN(User.balance) ){
				Bot.state = "screenshot_team_data";
				Bot.busy = false;
				clearInterval(balanceUpdateInterval);
			}
		}, 250);
	} else if( Bot.state == "screenshot_team_data" ){
		debug("Getting screenshot team data");
		Bot.analyzeScreenshot(function(){ // callback
			Bot.state = "check_team_data";
			Bot.busy = false;
		});	// analyze and parse screenshot
	} else if( Bot.state == "check_team_data" ){
		debug("Checking team data");
		Bot.analysis.valid = false;

		var bluePokemonInaccurate = [ read( "./blue_first.txt" ), read( "./blue_second.txt" ), read( "./blue_third.txt" ) ];
		var redPokemonInaccurate  = [ read( "./red_first.txt"  ), read( "./red_second.txt"  ), read( "./red_third.txt"  ) ];

		var bluePokemon = [],
			redPokemon  = [];

		bluePokemonInaccurate.forEach(function( name ){
			if(name){
				var closeObj = closestString( name, pokemonDictionary );
				if( closeObj.distance < ( 1/2 * closeObj.string.length ) ){	// if( name close enough to signify decent lookup )
					bluePokemon.push( pokemonDatabase[ closeObj.string ] );
				}
			}
		});

		redPokemonInaccurate.forEach(function( name ){
			if(name){
				var closeObj = closestString( name, pokemonDictionary );
				if( closeObj.distance < ( 1/2 * closeObj.string.length ) ){	// if( name close enough to signify decent lookup )
					redPokemon.push( pokemonDatabase[closeObj.string ] );
				}	
			}
			
		});

		if( bluePokemon.length + redPokemon.length === 6 ){
			// successfully found all six names, set names and change state to prevent a do-over
			Bot.analysis.blue.pokemon = bluePokemon;
			Bot.analysis.red.pokemon  = redPokemon;
			Bot.state = "populate_team_data";
		} else {
			// if condition not met, had trouble parsing names, either we aren't on the correct screen, or OCR had a tough time on a name. Do it again!
			Bot.state = "screenshot_team_data";
		}

		Bot.busy = false;

	} else if( Bot.state == "populate_team_data" ){
		debug("Populating team data");

		Bot.analysis.blue.damage = 0;
		Bot.analysis.red.damage = 0;
		Bot.analysis.blue.health = 0;
		Bot.analysis.red.health = 0;

		Bot.analysis.blue.pokemon.forEach(function( bluePokemon ){
			Bot.analysis.red.pokemon.forEach(function( redPokemon ){

				Bot.analysis.blue.damage += Bot.pokemonFirstAttacksSecond( bluePokemon, redPokemon );
				Bot.analysis.red.damage  += Bot.pokemonFirstAttacksSecond( redPokemon, bluePokemon );

			});
		});

		Bot.analysis.blue.pokemon.forEach(function( pokemon ){
			if( specialCases.health.hasOwnProperty( pokemon.name ) ){
				Bot.analysis.blue.health += specialCases.health[ pokemon.name ];
			} else {
				Bot.analysis.blue.health += Number( pokemon.hp );
			}
		});

		Bot.analysis.red.pokemon.forEach(function( pokemon ){
			if( specialCases.health.hasOwnProperty( pokemon.name ) ){
				Bot.analysis.red.health += specialCases.health[ pokemon.name ];
			} else {
				Bot.analysis.red.health += Number( pokemon.hp );
			}
		});

		// if all is well to this point
		Bot.analysis.valid = true;
		Bot.state = "place_bet";
		Bot.busy = false;

	} else if( Bot.state == "place_bet" ){

		debug("Placing bet");
		console.log("Betting phase");

        Bot.placeBet(function(){
        	Bot.state = "screenshot_team_data";
        	setTimeout(function(){
        		Bot.busy = false;
        	}, 60 * 2 * 1000); // wait 2 minutes before looking for the next team
        	
        	console.log("Callback happened");
        });
        
	}
}
Example #24
0
var Cory     = require('./app/Cory')
  , config   = require('./etc/config')
  , clc      = require('cli-color')
  , request  = require('request')
  , mongoose = require('mongoose')
  , irc      = require('irc')
  , jar      = request.jar()
  , options  = {}
  , cory     = new Cory()
  , Document = mongoose.model('Document', {image : String, url : String})
  , bot      = new irc.Client(config.server, config.botName, {
      channels: config.channels
    })
;

// if this site can authenticate, then do it
if (cory.canAuthenticate()) {
  options = cory.getAuthOptions(jar);
  request(options, function(error, response, body){
    if (error) {
      console.log(clc.red('ERROR') + ' - could not login');
    } else {
      console.log(clc.green('SUCCESS') + ' -  logged in ');
    }
  });
}

mongoose.connect(cory.getDsn(config));

// add the listener
bot.addListener('message', function(from, to, text, message) {
Example #25
0
client.connect(Infinity, function () {
	client.join(MAIN_CHANNEL);
});
Example #26
0
var irc = require('irc')
  , _ = require('underscore')._
  , fs = require('fs');
var client = new irc.Client(process.env.npm_package_config_server, process.env.npm_package_config_username, {
  debug: false,
  showErrors: true,
  autoRejoin: true,
  autoConnect: true,
  channels: [process.env.npm_package_config_channel],
  userName: process.env.npm_package_config_username,
  realName: 'Christina Node.js IRC Bot',
});
client.addListener('error', function(message) {
    if(message.command == 'err_notregistered' || message.rawCommand == 451) {
      client.say('NickServ','IDENTIFY '+process.env.npm_package_config_password);
    } else
      console.error('ERROR: %s: %s', message.command, message.args.join(' '));
});
client.addListener('notice', function (nick, to, text, message) {
  if(nick == 'NickServ') {
    if(text.match(/Password accepted/)) {
      client.emit('password_accepted');
    }
  }
});

var mods = [];
var reload = (function(){
  fs.readdir('./modules', function(err, files){
    if(err) { console.log(err); return; }
    _.each(files,function(file) {
Example #27
0
exports.create = function(api, settings) {
  if (settings.plugins && settings.plugins.irc && settings.plugins.irc.enable) {
    console.log('Creating the plugin: ' + __filename);
    var irc = require('irc');
    var channels = settings.plugins.irc.options.channels;
    var bot = new irc.Client(settings.plugins.irc.server, settings.plugins.irc.nick, settings.plugins.irc.options);
    var lastCount = 0;
    var lastService = {};
    var connected = false;
    var cache = [];
    var maxElements = settings.plugins.irc.maxElements || 10;

    bot.on('connect', function() {
      api.on('up', function(service) {
        checkChanges(service);
      });  

      api.on('down', function(service) {
        checkChanges(service);
      });  

      api.on('unknown', function(service) {
        checkChanges(service);
      });  

      api.on('critical', function(service) {
        checkChanges(service);
      });

      checkChanges = function(service) {
        if (!lastService[service.name]) {
          lastService[service.name] = {};
          lastService[service.name].status = 'up';
        }
        if (lastService[service.name].status != service.status) {
          if (service.status == 'up') {
            pushMessage("[" + service.status.toUpperCase() + "] " + service.name);
          } else {
            pushMessage("[" + service.status.toUpperCase() + "] " + service.name + ", Code: " +  service.statusCode + ", Message: " + service.message);
          }
        }
        lastService[service.name].status = service.status;
      };

      api.on('refresh', function(status) {
        var count = (status.summarize.critical + status.summarize.down + status.summarize.unknown).toString();
        if (lastCount != count) {
          var msg = 'Up: ' + status.summarize.up + ', ' + 'Critical: ' + status.summarize.critical + ', Down: ' + status.summarize.down + ', Unknown: ' + status.summarize.unknown;
          bot.say(channels, msg);
          lastCount = count;
        }
      });
    });

    bot.on('error', function(message) {
      console.error('ERROR: %s: %s', message.command, message.args.join(' '));
    });
    
    bot.on('join', function(channel, who) {
      console.log('%s has joined %s', who, channel);
      if (who == settings.plugins.irc.nick) {
        // TODO : Let's do it for each channel of the list...
        console.log('You are now connected to channel %s and ready to send messages', channel);
        connected = true;
        _.each(cache, function(message){
          bot.say(channels, message);
        });
        cache = [];
      }
    });
    
    // Add a private message listener to interact with the IRC bot
    bot.addListener('pm', function(nick, message) {
        console.log('Got private message from %s: %s', nick, message);
        var callme = commands[trim(message)];
        if (typeof callme !== 'undefined') {
          bot.say(nick, callme.call(null, api));
        } else {
          bot.say(nick, commands['help'].call(null, api));
        }
    });
  }
  
  // Send the message or cache it
  var pushMessage = function(message) {
    console.log('Pushing message %s ', message);
    if (connected) {
      bot.say(channels, message);
    } else {
      if (_.size(cache) < maxElements) {
        cache.push(message);
      }
    }
  }
  
  var commands = {
    status : function(api) {
      return 'Up: ' + api.getStatus().summarize.up + ', ' + 'Critical: ' + api.getStatus().summarize.critical + ', Down: ' + api.getStatus().summarize.down + ', Unknown: ' + api.getStatus().summarize.unknown;
    },
    list : function(api) {
      var result = '';
      _.each(api.getStatus().services, function(service){
        result += "[" + service.status.toUpperCase() + "] " + service.name + ", Code: " +  service.statusCode + ", Message: " + service.message + "\n";
      });
      return result;
    },
    help: function(api) {
      return "Available commands : \'list\', \'status\', \'help\'";
    }
  };
  
  var trim = function(string) {
    return string.replace(/^\s+/g,'').replace(/\s+$/g,'');
  }
};
Example #28
0
client.addListener('error', function(message) {
    if(message.command == 'err_notregistered' || message.rawCommand == 451) {
      client.say('NickServ','IDENTIFY '+process.env.npm_package_config_password);
    } else
      console.error('ERROR: %s: %s', message.command, message.args.join(' '));
});
Example #29
0
 bot.join(channel, function () {
     console.log('joined ' + channel);
     bot.say(channel, "servus!");
 });
Example #30
0
File: bot.js Project: Hayzer4/Dot
 resp.forEach(function (string) {
   bot.say(sendTo, string);
 });