https://github.com/ppvg/node-ircp
IRC protocol library for Node.js.
https://github.com/ppvg/node-ircp
Last synced: 2 months ago
JSON representation
IRC protocol library for Node.js.
- Host: GitHub
- URL: https://github.com/ppvg/node-ircp
- Owner: ppvg
- License: bsd-2-clause
- Created: 2013-07-17T08:29:46.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-17T13:58:21.000Z (almost 12 years ago)
- Last Synced: 2025-01-25T03:38:54.931Z (4 months ago)
- Language: LiveScript
- Homepage: https://npmjs.org/package/ircp
- Size: 188 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ircp
[](https://drone.io/github.com/PPvG/node-ircp/latest) [](https://drone.io/github.com/PPvG/node-ircp/files/coverage.html)
IRC protocol library for Node.js. Used to be part of [`ircc`](https://github.com/PPvG/node-ircc).
#### Installation
`$ npm install ircp`
#### Dependencies
Node.js 0.8.x or above.
## API
### ircp.parse(line)
### ircp.parser.parse(line)Takes an IRC message as raw text and returns a message object. A few examples (via the `node` REPL):
`> ircp.parse(':nick!user@host PART #channel');`
{ command: 'PART',
parameters: [ '#channel' ],
nick: 'nick',
user: 'user',
host: 'host',
type: 'command' }`> ircp.parse(':irc.example.com 001 botname :Welcome to the example IRC network!');`
{ command: 'WELCOME',
parameters:
[ 'botname',
'Welcome to the example IRC network!' ],
server: 'irc.example.com',
code: '001',
type: 'reply' }Throws an `Error` if the message can't be parsed.
### ircp.serialize(message)
### ircp.serializer.serialize(message)The reverse of `parser`. Takes a message object and turns it into a string.
`> ircp.serialize(ircp.parse(':nick!user@host PART #channel'));`
':nick!user@host PART #channel'
Throws an `Error` if the object is not a valid message.
### ircp.codes.convert()
Find the name and type of an IRC command. Known numeric commands are converted to their human-readable form. A few examples:
`> ircp.codes.convert('001');`
{ name: 'WELCOME', type: 'reply' }
`> ircp.codes.convert('401');`
{ name: 'NOSUCHNICK', type: 'error' }
`> ircp.codes.convert('NOTICE');`
{ name: 'NOTICE', type: 'command' }
Possible values for `type` are 'reply', 'error', 'command' and 'unknown'.