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

1. Go to this page and download the library: Download phergie/phergie-irc-plugin-react-command 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-command example snippets


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

    // Select how you'd like the command to be triggered. 
    // Only 1 method supported at a time so make sure to remove unused methods.

    'prefix' => '!', // string denoting the start of a command

    // or

    'pattern' => '/^!/', // PCRE regular expression denoting the presence of a
                         // command

    // or

    'nick' => true, // true to match common ways of addressing the bot by its
                    // connection nick

))

use Phergie\Irc\Plugin\React\Command\CommandEvent;
use Phergie\Irc\Bot\React\EventQueueInterface;
use Phergie\Irc\Bot\React\PluginInterface;

class FooPlugin implements PluginInterface
{
    public function getSubscribedEvents()
    {
        return array('command.foo' => 'handleFooCommand');
    }

    public function handleFooCommand(CommandEvent $event, EventQueueInterface $queue)
    {
        $commandName = $event->getCustomCommand();
        $fooParams = $event->getCustomParams();
        // ...
    }
}

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