https://github.com/leocavalcante/swoole-irc-client
💬 Swoole based IRC (Internet Relay Chat) Client
https://github.com/leocavalcante/swoole-irc-client
hacktoberfest irc-client swoole
Last synced: 10 months ago
JSON representation
💬 Swoole based IRC (Internet Relay Chat) Client
- Host: GitHub
- URL: https://github.com/leocavalcante/swoole-irc-client
- Owner: leocavalcante
- License: mit
- Created: 2020-10-13T19:47:18.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-14T19:53:10.000Z (over 5 years ago)
- Last Synced: 2025-03-29T22:41:18.525Z (about 1 year ago)
- Topics: hacktoberfest, irc-client, swoole
- Language: PHP
- Homepage: https://tools.ietf.org/html/rfc1459
- Size: 119 KB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swoole IRC Client
💬 [Swoole](https://www.swoole.co.uk/) based [IRC (Internet Relay Chat)](https://tools.ietf.org/html/rfc1459) Client.
## Installation
```bash
composer require leocavalcante/swoole-irc-client
```
## Usage
```php
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.
```php
use SwooleIrc\{Reply, Client, CallbackHandler};
$handler = static function (Reply $reply): void {};
$irc = Client::withHandler(CallbackHandler::reply($handler))
->connect($host, $port)
->start();
```
#### Examples
- [Twitch.tv Chatbot](https://github.com/leocavalcante/swoole-irc-client/tree/main/examples/twitch)
- [Freenode Chat CLI Client](https://github.com/leocavalcante/swoole-irc-client/tree/main/examples/freenode)
## Commands
### PASS
```php
$irc->pass($password);
```
### NICK
```php
$irc->nick($nickname);
```
### JOIN
```php
$irc->join([$channel]);
$irc->join([$channel], [$key]);
```
### PART
```php
$irc->part([$channel]);
```
### PRIVMSG
```php
$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)`.