• Stars
    star
    179
  • Rank 209,096 (Top 5 %)
  • Language
    JavaScript
  • License
    The Unlicense
  • Created over 14 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The best IRC library for node.js

IRC-js

The best IRC library for node.js

Installation

Via command-line:

npm install irc-js

Via package.json:

{ "dependencies":
  { "irc-js": "2" }
}

Tests

make test

2.0 Notes

We recently released the first beta of IRC-js 2.0. This release brings many changes, and documentation is not quite ready.

IRC-js 2.0 uses a couple of new ECMAScript features, so currently you must use the --harmony flag when running it.

So, for the adventurous, here's how to get started with 2.0:

/* IRC-js 2.0 provides a set of objects representing IRC entities, such as:
 *    Client    An IRC client, create one of these first.
 *    Message   A client sends and receives instances of this object.
 *    Channel   An IRC channel.
 *    Person    An IRC user.
 * Here follows a simple bot demonstrating basic usage.
 */

var irc = require("irc-js");

/* First, lets create an IRC Client.
 * The quickest way is to use the laziness function `irc.connect()`.
 * It takes an object configuring the bot, and returns a Client instance.
 */
irc.connect({ nick: "bot500" }, function(bot) {
  /* This optional callback means the client has connected.
   * It receives one argument: the Client instance.
   * Use the `join()` method to join a channel:
   */
  bot.join("#irc-js", function(err, chan) {
    /* You get this callback when the client has joined the channel.
     * The argument here is any eventual Error, and the Channel joined.
     */
    if (err) {
      console.log("Could not join channel :(", err);
      return;
    }
    /*
     * Channels also have some handy methods:
     */
    chan.say("Hello!");
  });

  /* You can also access channels like this:
   * `bot.channels.get("#irc-js").say("Hello!");`
   */

  /* Often you want your bot to do something when it receives a specific type
   * of message, or when a message contains something of interest.
   * The `match()` method lets you do both.
   * Look for INVITE messages and join channels:
   */
  bot.match("INVITE", function(msg) {
    /* Here the argument is a Message instance.
     * You can look at the `from` property to see who sent it.
     * The `reply()` method sends a message to the appropriate channel or person:
     */
    msg.reply("Thanks for the invite! On my way.");
    /* Sometimes you need to know about the parameters an IRC message uses.
     * The INVITE message has two: invitee and channel.
     */
    bot.join(msg.params[1]);
  });

  /* You can look for messages matching a regular expression.
   * Each match group is passed as an argument to the callback function.
   */
  bot.match(/\bsomecommand\s+([a-z]+)\s+([0-9]+)/, function(msg, letters, digits) {
    /* Here, the `letters` argument contains the text matched by the first group.
     * And `digits` is the second match. More match groups means more arguments.
     */
  });
});

More Repositories

1

dotfiles

Configurations for the tools I use every day
Emacs Lisp
1,040
star
2

sandbox

A nifty JavaScript sandbox for Node.js
JavaScript
836
star
3

Levenshtein

Javascript implementation of the L-diggity.
JavaScript
278
star
4

WAT

LOLWAT?
107
star
5

Jerk

Stupidly simple IRC bots in Javascript.
JavaScript
106
star
6

protobot

Prototype IRC Bot
JavaScript
57
star
7

haml.mode

HAML syntax definition for Coda & SubEthaEdit
44
star
8

texpand

Textarea auto-expander.
JavaScript
33
star
9

CLJBIN

A Clojure pastebin with code evaluation.
Clojure
33
star
10

TRNSFR

A Transmit 4-inspired multi progress bar.
JavaScript
22
star
11

butts

#butts
21
star
12

JS-strftime

Ruby-like strftime for javascript, because date-formatting is a pain.
JavaScript
18
star
13

hinttext

Hint text the right way.
JavaScript
14
star
14

peg.vim

PEG Syntax for Vim
Vim Script
14
star
15

coloured

Pretty colours in your terminal.
JavaScript
9
star
16

twatlr.com

Twatlr web service
JavaScript
8
star
17

molotov

The exciting colour scheme that will make you code goodâ„¢
Vim Script
6
star
18

Get-Off-My-Lawn

Safari version of Mike Taylor's "Get Off My Lawn" extension for Opera.
JavaScript
5
star
19

Rumen

Data extraction.
Ruby
5
star
20

butt.zone

What a nice place for a website.
HTML
5
star
21

oxpecker

Sandboxed javascript in ruby.
Ruby
4
star
22

docker-mongosh

Docker image for mongosh
Dockerfile
4
star
23

pancake

A user style to simplify waffle.io
CSS
4
star
24

clavatar-js

A ClojureScript port of Rayne's clavatar. This is a library to generate Gravatar URLs from email addresses.
JavaScript
4
star
25

snack

Please ignore
C
3
star
26

akahn-slash-asterisk

akahn/*
3
star
27

dom.js

Functional DOM-ination
JavaScript
3
star
28

Twatlr

Easy Twitter threads.
Racket
3
star
29

crapshot

crappy web screenshots (html → pdf)
C++
2
star
30

ring-cssgen

Ring middleware to automatically compile and regenerate your cssgen stylesheets.
Clojure
2
star
31

proto-misc

Miscellaneous tasty paste.
JavaScript
2
star
32

SCRLLR

Make great scrollings of the elements!!!
JavaScript
2
star
33

readthefuckingspec

Read the fucking spec.
Ruby
2
star
34

jennmoney.biz

the official site of olive garden's favorite twitter account
1
star
35

musex

Ruby
1
star
36

gf3

Private!
1
star
37

Resume

Curriculum Vitae
1
star
38

api-extractor-issue

TypeScript
1
star
39

ember-load-helpers

Autoload and register ember helpers
JavaScript
1
star