leocavalcante / swoole-irc-client
Swoole based IRC (Internet Relay Chat) Client
v0.1.0
2020-10-14 19:36 UTC
Requires
- php: >=7.4
- ext-swoole: ^4.5
- monolog/monolog: ^2.1
Requires (Dev)
- pestphp/pest: ^0.3.9
- phpunit/phpunit: ^9.4
- swoole/ide-helper: ^4.5
README
💬 Swoole based IRC (Internet Relay Chat) Client.
Installation
composer require leocavalcante/swoole-irc-client
Usage
use SwooleIrc\{HandlerInterface, Reply, Client}; class MyHandler implements HandlerInterface { public function onConnect(Client $irc): void {} public function onReply(Reply $reply, Client $irc): void {} } $irc = Client::withHandler(new MyHandler()); $irc->connect($host, $port); $irc->start();
CallbackHandler
This library provides a convenient way to pass a regular callable as well if you don't want to create a class and implement an interface.
use SwooleIrc\{Reply, Client, CallbackHandler}; $handler = static function (Reply $reply): void {}; $irc = Client::withHandler(CallbackHandler::reply($handler)) ->connect($host, $port) ->start();
Examples
Commands
PASS
$irc->pass($password);
NICK
$irc->nick($nickname);
JOIN
$irc->join([$channel]); $irc->join([$channel], [$key]);
PART
$irc->part([$channel]);
PRIVMSG
$irc->privmsg([$channel], $text);
Please, for now, take a look at the source code to see all supported commands.
And you can always implement MessageInterface
to send your own messages thought $irc->send(MessageInterface $message)
or send raw lines with $irc->writeln(string $raw)
.