GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tmijs/irc-parser

BranchesTags
Open more actions menu

Latest commit

 

History

31 Commits
31 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
scripts
scripts
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

@tmi.js/irc-parser

IRC parsing package for the @tmi.js/chat library

Install

npm i @tmi.js/irc-parser

Usage

import {
	parse, parseTagsFromString, parseTag, parsePrefix,
	format, formatTags, formatChannel, formatPrefix,
	unescapeIrc, escapeIrc
} from '@tmi.js/irc-parser';
import type {
	IrcMessage, ChannelString,
	ParsedTags, ParsedTagData, ParseTagCallbackFn,
	FormatMessage
} from '@tmi.js/irc-parser';

handleMessage('@a-number-key=123;a-boolean-key=true :[email protected] PRIVMSG #channel :Hello, world!');
// [#channel] <username> Hello, world!

function handleMessage(ircString: string) {
	const ircMessage = parse(ircString, (key, value, params) => {
		switch(key) {
			case 'a-number-key':
				return [ key, parseInt(value, 10) ];
			case 'a-boolean-key':
				return [ key, value === '1' || value === 'true' ];
		}
		return [ key, value ];
	});
	const { channel, command, params, prefix, tags } = ircMessage;
	switch(command) {
		case 'PING':
			ws.send(format({ command: 'PONG' }));
			break;
		case 'PRIVMSG':
			console.log(`[${channel}] <${prefix.user}> ${params[0]}`);
			if(params[0].startsWith('!help')) {
				ws.send(format({
					command: 'PRIVMSG',
					channel,
					params: [ helpString ]
				}));
			}
			break;
	}
}

About

No description, website, or topics provided.

Resources

Readme
MIT license
Activity
Custom properties

Stars

4 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.