Skip to content

komen205/tmi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Twitch Messaging Interface

Total Downloads Latest Stable Version License Discord

Introduction

Inspired by tmi.js and php-irc-client this package is a full featured, high performance Twitch IRC client written in PHP 7.4.

Also have a look at ghostzero/tmi-cluster. TMI Cluster is a Laravel package that makes the PHP TMI client scalable.

Features

  • Connecting to Twitch IRC with SSL
  • Generic IRC Commands
  • Supports Twitch IRC Tags (IRC v3)
  • Supports Twitch IRC Membership
  • Supports Twitch IRC Commands

Official Documentation

You can view our official documentation here.

Getting Started (w/o OAuth Token)

use GhostZero\Tmi\Client;
use GhostZero\Tmi\ClientOptions;
use GhostZero\Tmi\Events\Twitch\MessageEvent;

$client = new Client(new ClientOptions([
    'connection' => [
        'secure' => true,
        'reconnect' => true,
        'rejoin' => true,
    ],
    'channels' => ['ghostzero']
]));

$client->on(MessageEvent::class, function (MessageEvent $e) {
    print "{$e->tags['display-name']}: {$e->message}";
});

$client->connect();

Getting Started (w/ OAuth Token)

use GhostZero\Tmi\Client;
use GhostZero\Tmi\ClientOptions;
use GhostZero\Tmi\Events\Twitch\MessageEvent;

$client = new Client(new ClientOptions([
    'options' => ['debug' => true],
    'connection' => [
        'secure' => true,
        'reconnect' => true,
        'rejoin' => true,
    ],
    'identity' => [
        'username' => 'ghostzero',
        'password' => 'oauth:...',
    ],
    'channels' => ['ghostzero']
]));

$client->on(MessageEvent::class, function (MessageEvent $e) use ($client) {
    if ($e->self) return;

    if (strtolower($e->message) === '!hello') {
        $client->say($e->channel->getName(), "@{$e->user}, heya!");
    }
});

$client->connect();

About

PHP Twitch Messaging Interface

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%