]> git.localhorst.tv Git - alttp.git/blob - tests/Unit/TwitchBot/IRCMessageTest.php
better quota system for contextual messages
[alttp.git] / tests / Unit / TwitchBot / IRCMessageTest.php
1 <?php
2
3 namespace Tests\Unit\Models;
4
5 use App\TwitchBot\IRCMessage;
6 use PHPUnit\Framework\TestCase;
7
8 class IRCMessageTest extends TestCase {
9
10         public function test_interpretation() {
11                 $msg = IRCMessage::fromString('@badge-info=subscriber/7;badges=subscriber/6;client-nonce=779fa70677ceb5c85331030333796faf;color=#FF4500;display-name=Magnohato;emotes=emotesv2_fb9cdf0d7fae484ab2e1d20e59a17ed2:0-11,19-30,38-49,58-69,80-91,100-111,122-133,139-150;first-msg=0;flags=;id=4b6fc216-18de-41d0-b92d-aeb28c690788;mod=0;returning-chatter=0;room-id=30178469;subscriber=1;tmi-sent-ts=1712602818970;turbo=0;user-id=58325205;user-type= :magnohato!magnohato@magnohato.tmi.twitch.tv PRIVMSG #muftaay :muftaaKoomst spamt muftaaKoomst muffy muftaaKoomst diesen muftaaKoomst koomster muftaaKoomst  sonst muftaaKoomst  lose\'ed muftaaKoomst  er muftaaKoomst');
12                 $this->assertEqualsCanonicalizing([
13                         'badge-info' => 'subscriber/7',
14                         'badges' => 'subscriber/6',
15                         'client-nonce' => '779fa70677ceb5c85331030333796faf',
16                         'color' => '#FF4500',
17                         'display-name' => 'Magnohato',
18                         'emotes' => 'emotesv2_fb9cdf0d7fae484ab2e1d20e59a17ed2:0-11,19-30,38-49,58-69,80-91,100-111,122-133,139-150',
19                         'first-msg' => '0',
20                         'flags' => '',
21                         'id' => '4b6fc216-18de-41d0-b92d-aeb28c690788',
22                         'mod' => '0',
23                         'returning-chattea' => '0',
24                         'room-id' => '30178469',
25                         'subscriber' => '1',
26                         'tmi-sent-ts' => '1712602818970',
27                         'turbo' => '0',
28                         'user-id' => '58325205',
29                         'user-type' => '',
30                 ], $msg->tags);
31                 $this->assertEquals('PRIVMSG', $msg->command);
32                 $this->assertEquals('magnohato', $msg->nick);
33                 $this->assertEquals('muftaaKoomst spamt muftaaKoomst muffy muftaaKoomst diesen muftaaKoomst koomster muftaaKoomst  sonst muftaaKoomst  lose\'ed muftaaKoomst  er muftaaKoomst', $msg->getText());
34
35                 $msg = IRCMessage::fromString('@badge-info=subscriber/11;badges=vip/1,subscriber/6;client-nonce=14ed3e2b44129cd87b4ea21b597007a4;color=#8A2BE2;display-name=faker_jr_;emotes=;first-msg=0;flags=;id=7d37c395-acd7-401a-8d8a-f472f6317ee4;mod=0;reply-parent-display-name=Magnohato;reply-parent-msg-body=mein\sgegner\shatte\ssie\snicht;reply-parent-msg-id=9b33a360-0f71-40dc-af17-2d96c09b8d4a;reply-parent-user-id=58325205;reply-parent-user-login=magnohato;reply-thread-parent-display-name=Magnohato;reply-thread-parent-msg-id=9b33a360-0f71-40dc-af17-2d96c09b8d4a;reply-thread-parent-user-id=58325205;reply-thread-parent-user-login=magnohato;returning-chatter=0;room-id=30178469;subscriber=1;tmi-sent-ts=1712602877661;turbo=0;user-id=706291742;user-type=;vip=1 :faker_jr_!faker_jr_@faker_jr_.tmi.twitch.tv PRIVMSG #muftaay :@Magnohato  sumSmash');
36                 $this->assertEquals('PRIVMSG', $msg->command);
37                 $this->assertEquals('faker_jr_', $msg->nick);
38                 $this->assertEquals('@Magnohato  sumSmash', $msg->getText());
39
40                 $msg = IRCMessage::fromString('@badge-info=;badges=;color=;display-name=guentherspinx;emote-only=1;emotes=emotesv2_2ba58e42a974424ab706920026fc2569:0-8;first-msg=0;flags=;id=2dbabd7f-afd1-41cd-ad0e-2d4c5a961a46;mod=0;returning-chatter=0;room-id=30178469;subscriber=0;tmi-sent-ts=1712602890083;turbo=0;user-id=110816394;user-type= :guentherspinx!guentherspinx@guentherspinx.tmi.twitch.tv PRIVMSG #muftaay :muftaaHey');
41                 $this->assertEquals('PRIVMSG', $msg->command);
42                 $this->assertEquals('guentherspinx', $msg->nick);
43                 $this->assertEquals('muftaaHey', $msg->getText());
44
45                 $msg = IRCMessage::fromString('@badge-info=subscriber/7;badges=subscriber/6;client-nonce=86e4b1cdc575fbec97017840447ba70f;color=#FF4500;display-name=Magnohato;emote-only=1;emotes=555555560:0-1;first-msg=0;flags=;id=6df652f0-299f-4924-bcd9-f006d1b0ff97;mod=0;returning-chatter=0;room-id=30178469;subscriber=1;tmi-sent-ts=1712602892032;turbo=0;user-id=58325205;user-type= :magnohato!magnohato@magnohato.tmi.twitch.tv PRIVMSG #muftaay ::D');
46                 $this->assertEquals('PRIVMSG', $msg->command);
47                 $this->assertEquals('magnohato', $msg->nick);
48                 $this->assertEquals(':D', $msg->getText());
49         }
50
51 }