Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/Events/Twitch/ViewerMilestoneEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace GhostZero\Tmi\Events\Twitch;

use GhostZero\Tmi\Channel;
use GhostZero\Tmi\Events\Event;
use GhostZero\Tmi\Tags;
use GhostZero\Tmi\Traits\HasTagSignature;

class ViewerMilestoneEvent extends Event
{
use HasTagSignature;

/**
* @var Channel IRC Channel state object
*/
public Channel $channel;

/**
* @var string Username of the viewer
*/
public string $user;

/**
* @var int The number of consecutive streams the user has watched.
*/
public int $milestoneValue;

/**
* @var string Message category
*/
public string $category;

/**
* @var Tags Twitch Tags object
*/
public Tags $tags;



public function __construct(Channel $channel, string $user, int $milestoneValue, string $category, Tags $tags)
{
$this->channel = $channel;
$this->user = $user;
$this->milestoneValue = $milestoneValue;
$this->category = $category;
$this->tags = $tags;
}
}
1 change: 1 addition & 0 deletions src/Messages/IrcMessageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function parseSingle(string $message): IrcMessage
break;

case 'PRIVMSG':
case 'WHISPER':
$msg = new PrivmsgMessage($message);
break;

Expand Down
5 changes: 5 additions & 0 deletions src/Messages/UserNoticeMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class UserNoticeMessage extends IrcMessage
public const TAG_SUB = 'sub';
public const TAG_SUBGIFT = 'subgift';
public const TAG_SUBMYSTERYGIFT = 'submysterygift';
public const TAG_VIEWERMILESTONE = 'viewermilestone';

public Channel $channel;

Expand Down Expand Up @@ -68,6 +69,8 @@ public function getArguments(string $msgId): ?Event
$raidedChannel = $tags['msg-param-displayName'] ?? $tags['msg-param-login'] ?? '';
$viewers = (int)($tags['msg-param-viewerCount'] ?? 0);
$ritual = $tags['msg-param-ritual-name'] ?? '';
$category = $tags['msg-param-category'] ?? '';
$milestoneValue = (int)($tags['msg-param-value'] ?? 0);
$message = $this->payload ?? '';

switch ($msgId) {
Expand All @@ -93,6 +96,8 @@ public function getArguments(string $msgId): ?Event
return new Twitch\SubGiftEvent($this->channel, $username, $streakMonths, $recipient, $plan, $tags);
case self::TAG_SUBMYSTERYGIFT:
return new Twitch\SubMysteryGiftEvent($this->channel, $username, $giftSubCount, $plan, $tags);
case self::TAG_VIEWERMILESTONE:
return new Twitch\ViewerMilestoneEvent($this->channel, $username, $milestoneValue, $category, $tags);
default:
return null;
}
Expand Down