PHP code example of phergie / phergie-irc-plugin-react-eventfilter

1. Go to this page and download the library: Download phergie/phergie-irc-plugin-react-eventfilter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phergie / phergie-irc-plugin-react-eventfilter example snippets


new \Phergie\Irc\Plugin\React\EventFilter\Plugin(array(

    // All configuration is  implement \Phergie\Irc\Bot\React\PluginInterface
    'plugins' => array(
        // ...
    ),

    // Must reference an object that implements
    // \Phergie\Irc\Plugin\React\EventFilter\FilterInterface
    'filter' => new FooFilter,

))

use Phergie\Irc\Connection;
use Phergie\Irc\Plugin\React\AutoJoin\Plugin as AutoJoinPlugin;
use Phergie\Irc\Plugin\React\EventFilter as Filters;
use Phergie\Irc\Plugin\React\EventFilter\Plugin as EventFilterPlugin;
use Phergie\Irc\Plugin\React\JoinPart\Plugin as JoinPartPlugin;
use Phergie\Irc\Plugin\React\Pong\Plugin as PongPlugin;
use Phergie\Irc\Plugin\React\Quit\Plugin as QuitPlugin;
use Phergie\Irc\Plugin\React\UserMode\Plugin as UserModePlugin;

// These objects are instantiated and assigned to variables here because they
// are referenced multiple times later in the configuration array.
$connection1 = new Connection(array(
    // ...
));
$userModePlugin = new UserModePlugin;

return array(

    'connections' => array(

        $connection1,

        new Connection(array(
            // ...
        ))

    ),

    'plugins' => array(

        // These plugins apply to all connections.
        new PongPlugin,
        $userModePlugin,

        // Because of the applied ConnectionFilter, the bot will automatically
        // join #channel1 only on $connection1.
        new EventFilterPlugin(array(
            'filter' => new Filters\ConnectionFilter(array($connection1)),
            'plugins' => array(
                new AutoJoinPlugin(array('channels' => '#channel1')),
            ),
        )),

        // Because of the applied UserModeFilter, in order to request that the
        // bot join or part a channel, the requesting user must have the op
        // mode in that channel.
        new EventFilterPlugin(array(
            'filter' => new Filters\UserModeFilter($userModePlugin, array('o')),
            'plugins' => array(
                new JoinPartPlugin,
            ),
        )),

        // Because of the applied UserFilter, only the user with the specified
        // user mask will be able to request that the bot terminate its
        // connection to a server.
        new EventFilterPlugin(array(
            'filter' => new Filters\UserFilter(array('nick1!user1@host1')),
            'plugins' => array(
                new QuitPlugin,
            ),
        )),

    ),

);

new ChannelFilter(array(

    '#channel1',
    '&channel2',
    // ...

))

new ConnectionFilter(array(

    new \Phergie\Irc\Connection(array(
        // ...
    )),

    // ...
))

new UserFilter(array(

    'nick1!username1@host1',
    'nick2!username2@host2',
    // ...

))

new UserModeFilter(

    // Pre-configured instance of \Phergie\Irc\Plugin\React\UserMode\Plugin
    $userMode,

    // List of letters corresponding to user modes for which to allow events
    array('o', 'v')

)

new AndFilter(array(
    new ConnectionFilter(array($connection)),
    new ChannelFilter(array('#channel1', '&channel2')),
))

new AndFilter(array(
    new UserFilter(array('nick1!user1@host1')),
    new UserModeFilter($userModePlugin, array('o')),
))

new NotFilter(
    new UserFilter(array('nick1!user1@host1'))
)

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