Coder Social home page Coder Social logo

chaksoft / irclib Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 29 KB

JavaScript library to help you make an IRC robot or client in NodeJS

Home Page: https://www.npmjs.com/package/irclib

License: GNU General Public License v3.0

JavaScript 100.00%
irc irc-client irclib ircserver

irclib's Introduction

irclib

Library for making IRC clients

Table of Contents

  1. Installation
  2. Usage
    1. Options
    2. Events
    3. Components
  3. API Reference

Installation

$ npm install --save irclib

Usage

const { Client } = require('irclib')
const options = {
    //... See doc below
}

const client = new Client(options)
client.start()

Options

Option Description Default value Mandatory
host IP Address or hostname N/A Yes
port Port 6667 No
ssl SSL engine No No
channels List of default join channels [] No
partMessage Message when the lib parts from a channel [IrcLib] Good Bye. No
quitMessage Message when the lib disconnects from the server [IrcLib] Good Bye. No
password Password of the server '' No
encoding Text encoding utf8 No
version Response text of the CTCP version Version info in the package.json of your application No
user User information N/A Yes
nickname Initial nickname N/A Yes
realname Real name N/A Yes
alternative Alternative nickname Nickname + _ No
username User name N/A Yes
nickserv NickServ password if the nickname is registered N/A No
extra Custom application data for this client (must be an object) {} No
debugLevel Debug Level code (error, warning, info, debug) warning No

Events

Event Description
pubmsg Event received when a message is sent to a channel
privmsg Event received when a message is sent to the user
pubnotice Event received when a notice is sent to a channel
privnotice Event received when a notice is sent to the user
join Event received when an user joins a channel
part Event received when another user parts from a channel
quit Event receievd when another user quits
error Event received when the IRC server emits an error
nick Event received when an user changes his nickname
kick Event received when an user is kicked from a channel
ping Event received on a PING request
invite Event received when another user invites the user on a channel
mode Event received when a mode is changed

Every event callback takes 4 arguments :

  • sender: User information of the sender
  • middle: Middle information of the message
  • params: Array with other middle information
  • trailing: Trailing text of the message

There is a complete list of other events on this page. Every event can be bound by its numeric code or by a short version of the name. Example : RPL_WELCOME is bound to the welcome event.

Components

You can use components to make your code clear.

pubmsg.js

module.exports = (client) => {
    client.on('pubmsg', (sender, channel, message) => {
        console.log(`Message received from ${sender} on ${channel}: ${message}`)
    })
}

index.js

client.component(require('./pubmsg'))

API Reference

Class Client

on(event, callback)

Registers an event with a callback. Returns the client to allow event chaining.

start()

Starts the client by establishing the connection and listening for incoming data.

privmsg(target, message)

Sends a message to a channel or an user identified by target.

notice(target, message)

Sends a notice to a channel or an user identified by target.

action(target, message)

Sends a mIRC-styled action message (/me) to a channel or a user identified by target.

join(target)

Sends a join message to enter a channel identified by target.

part(target, message)

Sends a part message to leave a channel identified by target before leaving the channel.

quit(message)

Sends a quit message to the server before quitting the network.

mode(channel, modificators, targets = [])

Sends a mode message on a channel with inline modificators, eventually applied to targets.

irclib's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.