PHP code example of phergie / phergie-irc-client-react
1. Go to this page and download the library: Download phergie/phergie-irc-client-react 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-client-react example snippets
$connection = new \Phergie\Irc\Connection();
// ...
$client = new \Phergie\Irc\Client\React\Client();
$client->on('irc.received', function($message, $write, $connection, $logger) {
if ($message['command'] !== 'JOIN') {
return;
}
$channel = $message['params']['channels'];
$nick = $message['nick'];
$write->ircPrivmsg($channel, 'Welcome ' . $nick . '!');
});
$client->run($connection);
// Also works:
// $client->run(array($connection1, ..., $connectionN));
// Also possible:
// Don't autorun the event loopin case you pass your own event loop and run it yourself
// $client->run($connection, false);