|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace jofner\SDK\TwitchTV\Methods; |
|
4
|
|
|
|
|
5
|
|
|
use jofner\SDK\TwitchTV\TwitchRequest; |
|
6
|
|
|
use jofner\SDK\TwitchTV\TwitchException; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Chat method class for TwitchTV API SDK for PHP |
|
10
|
|
|
* |
|
11
|
|
|
* @author Josef Ohnheiser <[email protected]> |
|
12
|
|
|
* @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
|
13
|
|
|
* @homepage https://github.com/jofner/Twitch-SDK |
|
14
|
|
|
*/ |
|
15
|
|
View Code Duplication |
class Chat |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var TwitchRequest */ |
|
18
|
|
|
protected $request; |
|
19
|
|
|
|
|
20
|
|
|
const URI_CHAT = 'chat/'; |
|
21
|
|
|
const URI_CHAT_EMOTICONS = 'chat/emoticons'; |
|
22
|
|
|
const URI_CHAT_EMOTICONS_IMAGES = 'chat/emoticon_images'; |
|
23
|
|
|
const URI_CHAT_BADGES = 'chat/%s/badges'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Chat constructor |
|
27
|
|
|
* @param TwitchRequest $request |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct(TwitchRequest $request) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->request = $request; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Returns a links object to all other chat endpoints |
|
36
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatchannel |
|
37
|
|
|
* @param string $channel |
|
38
|
|
|
* @return \stdClass |
|
39
|
|
|
* @throws TwitchException |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getChat($channel) |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->request->request(self::URI_CHAT . $channel); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get a chat's emoticons |
|
48
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatemoticons |
|
49
|
|
|
* @return \stdClass |
|
50
|
|
|
* @throws TwitchException |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getEmoticons() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->request->request(self::URI_CHAT_EMOTICONS); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Returns a list of emoticons |
|
59
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatemoticon_images |
|
60
|
|
|
* @param string $queryString |
|
61
|
|
|
* @return \stdClass |
|
62
|
|
|
* @throws TwitchException |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getEmoticonImages($queryString) |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->request->request(self::URI_CHAT_EMOTICONS_IMAGES . $queryString); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Returns a list of chat badges that can be used in the :channel's chat |
|
71
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatchannelbadges |
|
72
|
|
|
* @param string $channel |
|
73
|
|
|
* @return \stdClass |
|
74
|
|
|
* @throws TwitchException |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getBadges($channel) |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->request->request(sprintf(self::URI_CHAT_BADGES, $channel)); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|