Git Product home page Git Product logo

phergie-irc-parser's Introduction

phergie/phergie-irc-parser

A PHP-based parser for messages conforming to the IRC protocol as described in RFC 1459 and RFC 2812.

Build Status

Install

The recommended method of installation is through composer.

{
    "require": {
        "phergie/phergie-irc-parser": "~1"
    }
}

Design goals

  • Minimal dependencies: PHP 5.4.2+ with the core PCRE extension
  • Can extract messages from a real-time data stream
  • Simple easy-to-understand API

Usage

<?php
$stream = ":Angel PRIVMSG Wiz :Hello are you receiving this message ?\r\n"
        . "PRIVMSG Angel :yes I'm receiving it !receiving it !'u>(768u+1n) .br\r\n";
$parser = new Phergie\Irc\Parser();

// Get one message without modifying $stream
// or null if no complete message is found
$message = $parser->parse($stream);

// Get one message and remove it from $stream
// or null if no complete message is found
$message = $parser->consume($stream);

// Get all messages without modifying $stream
// or an empty array if no complete messages are found
$messages = $parser->parseAll($stream);

// Get all messages and remove them from $stream
// or an empty array if no complete messages are found
$messages = $parser->consumeAll($stream);

/*
One parsed message looks like this:
array(
    'prefix' => ':Angel',
    'nick' => 'Angel',
    'command' => 'PRIVMSG',
    'params' => array(
        'receivers' => 'Wiz',
        'text' => 'Hello are you receiving this message ?',
        'all' => 'Wiz :Hello are you receiving this message ?',
    ),
    'targets' => array('Wiz'),
    'message' => ":Angel PRIVMSG Wiz :Hello are you receiving this message ?\r\n",
)
*/

Tests

To run the unit test suite:

curl -s https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit Phergie/Irc/ParserTest.php

License

Released under the BSD License. See LICENSE.

Community

Check out #phergie on irc.freenode.net or e-mail us at [email protected].

Related Projects

phergie-irc-parser's People

Contributors

elazar avatar renegade334 avatar svpernova09 avatar unlobito avatar rpasing avatar julien-c avatar

Watchers

 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.