---
title: "IRC Notification Bot With node.js"
description: "This bot is a product of a simple need of notifying people when their friends login to a particular channel. The need in JS."
url: "https://h3manth.com/scribe/irc-notification-bot-nodejs/"
canonical_url: "https://h3manth.com/scribe/irc-notification-bot-nodejs/"
markdown_url: "https://h3manth.com/scribe/blog/irc-notification-bot-nodejs.md"
publishDate: "2012-09-23T00:00:00.000Z"
author: "Hemanth HM"
category: "javascript"
tags: ["nodejs","git","web"]
word_count: 205
reading_time_minutes: 2
x_markdown_tokens: 465
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# IRC Notification Bot With node.js

> This bot is a product of a simple need of notifying people when their friends login to a particular channel. The need in JS.

This bot is a product of a simple need of notifying people when their friends login to a particular channel.

**The need :**

  * Simple IRC bot, that would notify its master.

  * Easy to configure.

  * Easy maintainability.

The answer was to do it with node.js!

**To get up and running :**

  * Indeed you must have node.

  * `npm install irc`

  * Check out the code from the [repo](https://github.com/hemanth/irc-notify) and edit `config.js` as per need.

  * Finally start the bot `node notify.js` and the pm notifications ;)

**The code :**

The config file : [ Power of JS objects FTW! ]

var config = {};

config.chans = "#yeoman, #html5"; config.server = "irc.freenode.net"; config.botName = "notify-bot"; config.friends = "firend1, firend2, firends3"; config.master = "hemanth"; module.exports = config; 

The bot :

## !/usr/bin/env node

var irc = require('irc'); var config = require('./config');

var chans = config.chans.split("/, _/"); var server = config.server; var botName = config.botName; var friends = config.friends.split(/,_ /); var master = config.master;

var bot = new irc.Client(server,botName, { channels: chans });

bot.addListener('join', function (channel, who) { console.log(who); console.log(friends.indexOf(who)); console.log(friends); if(friends.indexOf(who) >=0){
    
    
    bot.say(master,who + " joined "+channel); 
    

} }); 

Hope this helps, as it's helping me. Your suggestions are welcome, do check out [l33ty](http://h3manth.com/content/python-irc-bot)
