twitchrb 0.2.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +182 -5
- data/bin/console +1 -1
- data/lib/twitch/client.rb +30 -3
- data/lib/twitch/objects/automod_setting.rb +4 -0
- data/lib/twitch/objects/automod_status.rb +4 -0
- data/lib/twitch/objects/blocked_term.rb +4 -0
- data/lib/twitch/objects/raid.rb +4 -0
- data/lib/twitch/objects/user_color.rb +4 -0
- data/lib/twitch/objects/vip.rb +4 -0
- data/lib/twitch/resource.rb +2 -0
- data/lib/twitch/resources/announcements.rb +12 -0
- data/lib/twitch/resources/automod.rb +37 -0
- data/lib/twitch/resources/banned_users.rb +14 -0
- data/lib/twitch/resources/blocked_terms.rb +27 -0
- data/lib/twitch/resources/chat_messages.rb +10 -0
- data/lib/twitch/resources/moderators.rb +8 -0
- data/lib/twitch/resources/raids.rb +19 -0
- data/lib/twitch/resources/users.rb +19 -0
- data/lib/twitch/resources/vips.rb +19 -0
- data/lib/twitch/resources/whispers.rb +9 -0
- data/lib/twitch/version.rb +1 -1
- data/lib/twitch.rb +13 -0
- metadata +19 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4921296177c80efd1a41535907c5e2e1ce41a6c6695e319f968a2d9bc5012e34
|
4
|
+
data.tar.gz: 4ad72356f24394069cbf9a2845038db485d75fc9a273446665a18ad59b15274a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b39f99a455e2d7b02d4c537b55e52576f2a5f232e488a90d3e48480621bec11ab92c9994c9119bacd402f3852654944103a7a1eb0b67e1d1d299e22471c3a9c0
|
7
|
+
data.tar.gz: 2cd4c7b9c6582e9d337343b2dd81f9c8c14b81954dbe6795496115602e6cdd78e2809c8d5f0a004cdcb27602b271a96d68778a85720a31292db999c00f663839
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
twitchrb (0.
|
4
|
+
twitchrb (1.0.0)
|
5
5
|
faraday (~> 2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
dotenv (2.7.6)
|
11
|
-
faraday (2.
|
11
|
+
faraday (2.3.0)
|
12
12
|
faraday-net_http (~> 2.0)
|
13
13
|
ruby2_keywords (>= 0.0.4)
|
14
|
-
faraday-net_http (2.0.
|
14
|
+
faraday-net_http (2.0.3)
|
15
15
|
minitest (5.15.0)
|
16
16
|
rake (12.3.3)
|
17
17
|
ruby2_keywords (0.0.5)
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# TwitchRB
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TwitchRB is a Ruby library for intereacting with the Twitch Helix API.
|
3
|
+
TwitchRB is a Ruby library for interacting with the Twitch Helix API.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -16,12 +14,12 @@ gem "twitchrb"
|
|
16
14
|
|
17
15
|
### Set Client Details
|
18
16
|
|
19
|
-
Firstly you'll need to set a Client ID
|
17
|
+
Firstly you'll need to set a Client ID and an Access Token.
|
20
18
|
|
21
19
|
An access token is required because the Helix API requires authentication.
|
22
20
|
|
23
21
|
```ruby
|
24
|
-
@client = Twitch::Client.new(client_id: "",
|
22
|
+
@client = Twitch::Client.new(client_id: "", access_token: "")
|
25
23
|
```
|
26
24
|
|
27
25
|
### Users
|
@@ -56,6 +54,19 @@ An access token is required because the Helix API requires authentication.
|
|
56
54
|
# Required scope: user:manage:blocked_users
|
57
55
|
@client.users.unblock_user(target_user_id: 141981764)
|
58
56
|
|
57
|
+
# Get a User's Chat Color
|
58
|
+
@client.users.get_color(user_id: 123)
|
59
|
+
|
60
|
+
# Or get multiple users' chat colors
|
61
|
+
# Returns a collection
|
62
|
+
@client.users.get_color(user_ids: "123,321")
|
63
|
+
|
64
|
+
# Update a User's Chat Color
|
65
|
+
# Requires user:manage:chat_color
|
66
|
+
# user_id must be the currently authenticated user
|
67
|
+
# Current allowed colours: blue, blue_violet, cadet_blue, chocolate, coral, dodger_blue, firebrick, golden_rod, green, hot_pink, orange_red, red, sea_green, spring_green, yellow_green
|
68
|
+
# For Turbo and Prime users, a hex colour code is allowed.
|
69
|
+
@client.users.update_color(user_id: 123, color: "blue")
|
59
70
|
```
|
60
71
|
|
61
72
|
### Channels
|
@@ -185,6 +196,172 @@ These require an application OAuth access token.
|
|
185
196
|
@client.banned_users.list(broadcaster_id: 123)
|
186
197
|
```
|
187
198
|
|
199
|
+
```ruby
|
200
|
+
# Ban/Timeout a user from a broadcaster's channel
|
201
|
+
# Required scope: moderator:manage:banned_users
|
202
|
+
# A reason is required
|
203
|
+
# To time a user out, a duration is required. If no duration is set, the user will be banned.
|
204
|
+
@client.banned_users.create broadcaster_id: 123, moderator_id: 321, user_id: 112233, reason: "testing", duration: 60
|
205
|
+
```
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
# Unban/untimeout a user from a broadcaster's channel
|
209
|
+
# Required scope: moderator:manage:banned_users
|
210
|
+
@client.banned_users.delete broadcaster_id: 123, moderator_id: 321, user_id: 112233
|
211
|
+
```
|
212
|
+
|
213
|
+
## Send Chat Announcement
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
# Sends an announcement to the broadcaster's chat room
|
217
|
+
# Requires moderator:manage:announcements
|
218
|
+
# moderator_id can be either the currently authenticated moderator or the broadcaster
|
219
|
+
# color can be either blue, green, orange, purple, primary. If left blank, primary is default
|
220
|
+
@client.announcements.create broadcaster_id: 123, moderator_id: 123, message: "test message", color: "purple"
|
221
|
+
```
|
222
|
+
|
223
|
+
## Moderators
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
# List all moderators for a broadcaster
|
227
|
+
# Required scope: moderation:read
|
228
|
+
# broadcaster_id must be the currently authenticated user
|
229
|
+
@client.moderators.list broadcaster_id: 123
|
230
|
+
```
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
# Add a Moderator
|
234
|
+
# Required scope: channel:manage:moderators
|
235
|
+
# broadcaster_id must be the currently authenticated user
|
236
|
+
@client.moderators.create broadcaster_id: 123, user_id: 321
|
237
|
+
```
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
# Remove a Moderator
|
241
|
+
# Required scope: channel:manage:moderators
|
242
|
+
# broadcaster_id must be the currently authenticated user
|
243
|
+
@client.moderators.delete broadcaster_id: 123, user_id: 321
|
244
|
+
```
|
245
|
+
|
246
|
+
## VIPs
|
247
|
+
|
248
|
+
```ruby
|
249
|
+
# List all VIPs for a broadcaster
|
250
|
+
# Required scope: channel:read:vips or channel:manage:vips
|
251
|
+
# broadcaster_id must be the currently authenticated user
|
252
|
+
@client.vips.list broadcaster_id: 123
|
253
|
+
```
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
# Add a VIP
|
257
|
+
# Required scope: channel:manage:vips
|
258
|
+
# broadcaster_id must be the currently authenticated user
|
259
|
+
@client.vips.create broadcaster_id: 123, user_id: 321
|
260
|
+
```
|
261
|
+
|
262
|
+
```ruby
|
263
|
+
# Remove a VIP
|
264
|
+
# Required scope: channel:manage:vips
|
265
|
+
# broadcaster_id must be the currently authenticated user
|
266
|
+
@client.vips.delete broadcaster_id: 123, user_id: 321
|
267
|
+
```
|
268
|
+
|
269
|
+
## Raids
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
# Starts a raid
|
273
|
+
# Requires channel:manage:raids
|
274
|
+
# from_broadcaster_id must be the authenticated user
|
275
|
+
@client.raids.create from_broadcaster_id: 123, to_broadcaster_id: 321
|
276
|
+
```
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
# Requires channel:manage:raids
|
280
|
+
# broadcaster_id must be the authenticated user
|
281
|
+
@client.raids.delete broadcaster_id: 123
|
282
|
+
```
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
# Removes a single chat message from the broadcaster's chat room
|
286
|
+
# Requires moderator:manage:chat_messages
|
287
|
+
# moderator_id can be either the currently authenticated moderator or the broadcaster
|
288
|
+
@client.chat_messages.delete broadcaster_id: 123, moderator_id: 123, message_id: "abc123-abc123"
|
289
|
+
```
|
290
|
+
|
291
|
+
## Whispers
|
292
|
+
|
293
|
+
```ruby
|
294
|
+
# Send a Whisper
|
295
|
+
# Required scope: user:manage:whispers
|
296
|
+
# from_user_id must be the currently authenticated user's ID and have a verified phone number
|
297
|
+
@client.whispers.create from_user_id: 123, to_user_id: 321, message: "this is a test"
|
298
|
+
```
|
299
|
+
|
300
|
+
## AutoMod
|
301
|
+
|
302
|
+
```ruby
|
303
|
+
# Check if a message meets the channel's AutoMod requirements
|
304
|
+
# Required scope: moderation:read
|
305
|
+
# id is a developer-generated identifier for mapping messages to results.
|
306
|
+
@client.automod.check_status_multiple broadcaster_id: 123, id: "abc123", text: "Is this message allowed?"
|
307
|
+
|
308
|
+
#> #<Twitch::AutomodStatus msg_id="abc123", is_permitted=true>
|
309
|
+
```
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
# Check if multiple messages meet the channel's AutoMod requirements
|
313
|
+
# messages must be an array of hashes and must include msg_id and msg_text
|
314
|
+
# Returns a collection
|
315
|
+
messages = [{msg_id: "abc1", msg_text: "is this allowed?"}, {msg_id: "abc2", msg_text: "What about this?"}]
|
316
|
+
@client.automod.check_status_multiple broadcaster_id: 123, messages: messages
|
317
|
+
```
|
318
|
+
|
319
|
+
```ruby
|
320
|
+
# Get AutoMod settings
|
321
|
+
# Required scope: moderator:read:automod_settings
|
322
|
+
# moderator_id can be either the currently authenticated moderator or the broadcaster
|
323
|
+
@client.automod.settings broadcaster_id: 123, moderator_id: 321
|
324
|
+
```
|
325
|
+
|
326
|
+
```ruby
|
327
|
+
# Update AutoMod settings
|
328
|
+
# Required scope: moderator:manage:automod_settings
|
329
|
+
# moderator_id can be either the currently authenticated moderator or the broadcaster
|
330
|
+
# As this is a PUT method, it overwrites all options so all fields you want set should be supplied
|
331
|
+
@client.automod.update_settings broadcaster_id: 123, moderator_id: 321, swearing: 1
|
332
|
+
```
|
333
|
+
|
334
|
+
## Creator Goals
|
335
|
+
|
336
|
+
```ruby
|
337
|
+
# List all active creator goals
|
338
|
+
# Required scope: channel:read:goals
|
339
|
+
# broadcaster_id must match the currently authenticated user
|
340
|
+
@client.goals.list broadcaster_id: 123
|
341
|
+
```
|
342
|
+
|
343
|
+
## Blocked Terms
|
344
|
+
|
345
|
+
```ruby
|
346
|
+
# List all blocked terms
|
347
|
+
# Required scope: moderator:read:blocked_terms
|
348
|
+
# moderator_id can be either the currently authenticated moderator or the broadcaster
|
349
|
+
@client.blocked_terms.list broadcaster_id: 123, moderator_id: 321
|
350
|
+
```
|
351
|
+
|
352
|
+
```ruby
|
353
|
+
# Create a blocked term
|
354
|
+
# Required scope: moderator:manage:blocked_terms
|
355
|
+
# moderator_id can be either the currently authenticated moderator or the broadcaster
|
356
|
+
@client.blocked_terms.create broadcaster_id: 123, moderator_id: 321, text: "term to block"
|
357
|
+
```
|
358
|
+
|
359
|
+
```ruby
|
360
|
+
# Delete a blocked term
|
361
|
+
# Required scope: moderator:manage:blocked_terms
|
362
|
+
# moderator_id can be either the currently authenticated moderator or the broadcaster
|
363
|
+
@client.blocked_terms.delete broadcaster_id: 123, moderator_id: 321, id: "abc12-12abc"
|
364
|
+
```
|
188
365
|
|
189
366
|
## Contributing
|
190
367
|
|
data/bin/console
CHANGED
@@ -13,7 +13,7 @@ require 'dotenv/load'
|
|
13
13
|
# require "pry"
|
14
14
|
# Pry.start
|
15
15
|
|
16
|
-
@client = Twitch::Client.new(client_id: ENV["TWITCH_CLIENT_ID"],
|
16
|
+
@client = Twitch::Client.new(client_id: ENV["TWITCH_CLIENT_ID"], access_token: ENV["TWITCH_ACCESS_TOKEN"])
|
17
17
|
|
18
18
|
require "irb"
|
19
19
|
IRB.start(__FILE__)
|
data/lib/twitch/client.rb
CHANGED
@@ -2,11 +2,10 @@ module Twitch
|
|
2
2
|
class Client
|
3
3
|
BASE_URL = "https://api.twitch.tv/helix"
|
4
4
|
|
5
|
-
attr_reader :client_id, :
|
5
|
+
attr_reader :client_id, :access_token, :adapter
|
6
6
|
|
7
|
-
def initialize(client_id:,
|
7
|
+
def initialize(client_id:, access_token:, adapter: Faraday.default_adapter, stubs: nil)
|
8
8
|
@client_id = client_id
|
9
|
-
@client_secret = client_secret
|
10
9
|
@access_token = access_token
|
11
10
|
@adapter = adapter
|
12
11
|
|
@@ -110,6 +109,34 @@ module Twitch
|
|
110
109
|
HypeTrainEventsResource.new(self)
|
111
110
|
end
|
112
111
|
|
112
|
+
def announcements
|
113
|
+
AnnouncementsResource.new(self)
|
114
|
+
end
|
115
|
+
|
116
|
+
def raids
|
117
|
+
RaidsResource.new(self)
|
118
|
+
end
|
119
|
+
|
120
|
+
def chat_messages
|
121
|
+
ChatMessagesResource.new(self)
|
122
|
+
end
|
123
|
+
|
124
|
+
def vips
|
125
|
+
VipsResource.new(self)
|
126
|
+
end
|
127
|
+
|
128
|
+
def whispers
|
129
|
+
WhispersResource.new(self)
|
130
|
+
end
|
131
|
+
|
132
|
+
def automod
|
133
|
+
AutomodResource.new(self)
|
134
|
+
end
|
135
|
+
|
136
|
+
def blocked_terms
|
137
|
+
BlockedTermsResource.new(self)
|
138
|
+
end
|
139
|
+
|
113
140
|
def connection
|
114
141
|
@connection ||= Faraday.new(BASE_URL) do |conn|
|
115
142
|
conn.request :authorization, :Bearer, access_token
|
data/lib/twitch/resource.rb
CHANGED
@@ -40,6 +40,8 @@ module Twitch
|
|
40
40
|
raise Error, "Error 404: No results were found for your request. '#{response.body["error"]}'"
|
41
41
|
when 409
|
42
42
|
raise Error, "Error 409: Your request was a conflict. '#{response.body["message"]}'"
|
43
|
+
when 422
|
44
|
+
raise Error, "Error 422: Unprocessable Entity. '#{response.body["message"]}"
|
43
45
|
when 429
|
44
46
|
raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["error"]}'"
|
45
47
|
when 500
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Twitch
|
2
|
+
class AnnouncementsResource < Resource
|
3
|
+
|
4
|
+
# Moderator ID must match the user in the OAuth token
|
5
|
+
def create(broadcaster_id:, moderator_id:, message:, color: nil)
|
6
|
+
attrs = {message: message, color: color}
|
7
|
+
|
8
|
+
post_request("chat/announcements?broadcaster_id=#{broadcaster_id}&moderator_id=#{moderator_id}", body: attrs)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Twitch
|
2
|
+
class AutomodResource < Resource
|
3
|
+
|
4
|
+
# Checks if a supplied message meets the channel's AutoMod requirements
|
5
|
+
# Required scope: moderation:read
|
6
|
+
def check_status(broadcaster_id:, id:, text:)
|
7
|
+
attrs = {broadcaster_id: broadcaster_id, data: [{msg_id: id, msg_text: text}]}
|
8
|
+
response = post_request("moderation/enforcements/status", body: attrs)
|
9
|
+
AutomodStatus.new response.body.dig("data")[0]
|
10
|
+
end
|
11
|
+
|
12
|
+
# Checks if multiple supplied messages meet the channel's AutoMod requirements
|
13
|
+
# Required scope: moderation:read
|
14
|
+
def check_status_multiple(broadcaster_id:, messages:)
|
15
|
+
attrs = {broadcaster_id: broadcaster_id, data: messages}
|
16
|
+
response = post_request("moderation/enforcements/status", body: attrs)
|
17
|
+
Collection.from_response(response, type: AutomodStatus)
|
18
|
+
end
|
19
|
+
|
20
|
+
def manage_message(user_id:, msg_id:, action:)
|
21
|
+
attrs = {user_id: user_id, msg_id: msg_id, action: action}
|
22
|
+
post_request("moderation/automod/message", body: attrs)
|
23
|
+
end
|
24
|
+
|
25
|
+
def settings(broadcaster_id:, moderator_id:)
|
26
|
+
response = get_request("moderation/automod/settings?broadcaster_id=#{broadcaster_id}&moderator_id=#{moderator_id}")
|
27
|
+
AutomodSetting.new response.body.dig("data")[0]
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_settings(broadcaster_id:, moderator_id:, **params)
|
31
|
+
attrs = {broadcaster_id: broadcaster_id, moderator_id: moderator_id}
|
32
|
+
response = put_request("moderation/automod/settings", body: attrs.merge(params))
|
33
|
+
AutomodSetting.new response.body.dig("data")[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -7,5 +7,19 @@ module Twitch
|
|
7
7
|
Collection.from_response(response, type: BannedUser)
|
8
8
|
end
|
9
9
|
|
10
|
+
# Required scope: moderator:manage:banned_users
|
11
|
+
# moderator_id must match the currently authenticated user. Can be either the broadcaster ID or moderator ID
|
12
|
+
def create(broadcaster_id:, moderator_id:, user_id:, reason:, duration: nil)
|
13
|
+
attrs = {broadcaster_id: broadcaster_id, moderator_id: moderator_id, data: {user_id: user_id, reason: reason, duration: duration}}
|
14
|
+
response = post_request("moderation/bans", body: attrs)
|
15
|
+
BannedUser.new response.body.dig("data")[0]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Required scope: moderator:manage:banned_users
|
19
|
+
# moderator_id must match the currently authenticated user. Can be either the broadcaster ID or moderator ID
|
20
|
+
def delete(broadcaster_id:, moderator_id:, user_id:)
|
21
|
+
delete_request("moderation/bans?broadcaster_id=#{broadcaster_id}&moderator_id=#{moderator_id}&user_id=#{user_id}")
|
22
|
+
end
|
23
|
+
|
10
24
|
end
|
11
25
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Twitch
|
2
|
+
class BlockedTermsResource < Resource
|
3
|
+
|
4
|
+
# Required scope: moderator:read:blocked_terms
|
5
|
+
# moderator_id must match the currently authenticated user. Can be either the broadcaster ID or moderator ID
|
6
|
+
def list(broadcaster_id:, moderator_id:, **params)
|
7
|
+
attrs = {broadcaster_id: broadcaster_id, moderator_id: moderator_id}
|
8
|
+
response = get_request("moderation/blocked_terms", params: attrs.merge(params))
|
9
|
+
Collection.from_response(response, type: BlockedTerm)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Required scope: moderator:manage:blocked_terms
|
13
|
+
# moderator_id must match the currently authenticated user. Can be either the broadcaster ID or moderator ID
|
14
|
+
def create(broadcaster_id:, moderator_id:, text:)
|
15
|
+
attrs = {broadcaster_id: broadcaster_id, moderator_id: moderator_id, text: text}
|
16
|
+
response = post_request("moderation/blocked_terms", body: attrs)
|
17
|
+
BannedUser.new response.body.dig("data")[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Required scope: moderator:manage:blocked_terms
|
21
|
+
# moderator_id must match the currently authenticated user. Can be either the broadcaster ID or moderator ID
|
22
|
+
def delete(broadcaster_id:, moderator_id:, id:)
|
23
|
+
delete_request("moderation/blocked_terms?broadcaster_id=#{broadcaster_id}&moderator_id=#{moderator_id}&id=#{id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Twitch
|
2
|
+
class ChatMessagesResource < Resource
|
3
|
+
|
4
|
+
# moderator_id must match the user in the OAuth token
|
5
|
+
def delete(broadcaster_id:, moderator_id:, message_id:)
|
6
|
+
delete_request("moderation/chat?broadcaster_id=#{broadcaster_id}&moderator_id=#{moderator_id}&message_id=#{message_id}")
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
@@ -7,5 +7,13 @@ module Twitch
|
|
7
7
|
Collection.from_response(response, type: Moderator)
|
8
8
|
end
|
9
9
|
|
10
|
+
def create(broadcaster_id:, user_id:)
|
11
|
+
post_request("moderation/moderators", body: {broadcaster_id: broadcaster_id, user_id: user_id})
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete(broadcaster_id:, user_id:)
|
15
|
+
delete_request("moderation/moderators?broadcaster_id=#{broadcaster_id}&user_id=#{user_id}")
|
16
|
+
end
|
17
|
+
|
10
18
|
end
|
11
19
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Twitch
|
2
|
+
class RaidsResource < Resource
|
3
|
+
|
4
|
+
# from_broadcaster_id must match the user in the OAuth token
|
5
|
+
def create(from_broadcaster_id:, to_broadcaster_id:)
|
6
|
+
attrs = {from_broadcaster_id: from_broadcaster_id, to_broadcaster_id: to_broadcaster_id}
|
7
|
+
|
8
|
+
response = post_request("raids", body: attrs)
|
9
|
+
|
10
|
+
Raid.new(response.body.dig("data")[0]) if response.success?
|
11
|
+
end
|
12
|
+
|
13
|
+
# broadcaster_id must match the user in the OAuth token
|
14
|
+
def delete(broadcaster_id:)
|
15
|
+
delete_request("raids?broadcaster_id=#{broadcaster_id}")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -16,6 +16,25 @@ module Twitch
|
|
16
16
|
User.new response.body.dig("data")[0]
|
17
17
|
end
|
18
18
|
|
19
|
+
def get_color(user_id: nil, user_ids: nil)
|
20
|
+
if user_ids != nil
|
21
|
+
users = user_ids.split(",").map{|i| "user_id=#{i.strip}"}.join("&")
|
22
|
+
puts "chat/color?#{users}"
|
23
|
+
response = get_request("chat/color?#{users}")
|
24
|
+
Collection.from_response(response, type: UserColor)
|
25
|
+
else
|
26
|
+
response = get_request("chat/color?user_id=#{user_id}")
|
27
|
+
UserColor.new response.body.dig("data")[0]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Update a user's color
|
32
|
+
# Required scope: user:manage:chat_color
|
33
|
+
# user_id must be the currently authenticated user
|
34
|
+
def update_color(user_id:, color:)
|
35
|
+
put_request("chat/color?user_id=#{user_id}&color=#{color}", body: {})
|
36
|
+
end
|
37
|
+
|
19
38
|
def follows(**params)
|
20
39
|
raise "from_id or to_id is required" unless !params[:from_id].nil? || !params[:to_id].nil?
|
21
40
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Twitch
|
2
|
+
class VipsResource < Resource
|
3
|
+
|
4
|
+
# Broadcaster ID must match the user in the OAuth token
|
5
|
+
def list(broadcaster_id:, **params)
|
6
|
+
response = get_request("channels/vips", params: params.merge(broadcaster_id: broadcaster_id))
|
7
|
+
Collection.from_response(response, type: Vip)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(broadcaster_id:, user_id:)
|
11
|
+
post_request("channels/vips", body: {broadcaster_id: broadcaster_id, user_id: user_id})
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete(broadcaster_id:, user_id:)
|
15
|
+
delete_request("channels/vips?broadcaster_id=#{broadcaster_id}&user_id=#{user_id}")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/twitch/version.rb
CHANGED
data/lib/twitch.rb
CHANGED
@@ -35,6 +35,13 @@ module Twitch
|
|
35
35
|
autoload :CustomRewardRedemptionsResource, "twitch/resources/custom_reward_redemptions"
|
36
36
|
autoload :GoalsResource, "twitch/resources/goals"
|
37
37
|
autoload :HypeTrainEventsResource, "twitch/resources/hype_train_events"
|
38
|
+
autoload :AnnouncementsResource, "twitch/resources/announcements"
|
39
|
+
autoload :RaidsResource, "twitch/resources/raids"
|
40
|
+
autoload :ChatMessagesResource, "twitch/resources/chat_messages"
|
41
|
+
autoload :VipsResource, "twitch/resources/vips"
|
42
|
+
autoload :WhispersResource, "twitch/resources/whispers"
|
43
|
+
autoload :AutomodResource, "twitch/resources/automod"
|
44
|
+
autoload :BlockedTermsResource, "twitch/resources/blocked_terms"
|
38
45
|
|
39
46
|
|
40
47
|
autoload :User, "twitch/objects/user"
|
@@ -67,5 +74,11 @@ module Twitch
|
|
67
74
|
autoload :Goal, "twitch/objects/goal"
|
68
75
|
autoload :HypeTrainEvent, "twitch/objects/hype_train_event"
|
69
76
|
autoload :FollowCount, "twitch/objects/follow_count"
|
77
|
+
autoload :Raid, "twitch/objects/raid"
|
78
|
+
autoload :UserColor, "twitch/objects/user_color"
|
79
|
+
autoload :Vip, "twitch/objects/vip"
|
80
|
+
autoload :AutomodStatus, "twitch/objects/automod_status"
|
81
|
+
autoload :AutomodSetting, "twitch/objects/automod_setting"
|
82
|
+
autoload :BlockedTerm, "twitch/objects/blocked_term"
|
70
83
|
|
71
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitchrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- dean@deanpcmad.com
|
30
30
|
executables: []
|
@@ -47,9 +47,12 @@ files:
|
|
47
47
|
- lib/twitch/collection.rb
|
48
48
|
- lib/twitch/error.rb
|
49
49
|
- lib/twitch/object.rb
|
50
|
+
- lib/twitch/objects/automod_setting.rb
|
51
|
+
- lib/twitch/objects/automod_status.rb
|
50
52
|
- lib/twitch/objects/badge.rb
|
51
53
|
- lib/twitch/objects/banned_event.rb
|
52
54
|
- lib/twitch/objects/banned_user.rb
|
55
|
+
- lib/twitch/objects/blocked_term.rb
|
53
56
|
- lib/twitch/objects/blocked_user.rb
|
54
57
|
- lib/twitch/objects/channel.rb
|
55
58
|
- lib/twitch/objects/channel_editor.rb
|
@@ -67,6 +70,7 @@ files:
|
|
67
70
|
- lib/twitch/objects/moderator_event.rb
|
68
71
|
- lib/twitch/objects/poll.rb
|
69
72
|
- lib/twitch/objects/prediction.rb
|
73
|
+
- lib/twitch/objects/raid.rb
|
70
74
|
- lib/twitch/objects/search_result.rb
|
71
75
|
- lib/twitch/objects/stream.rb
|
72
76
|
- lib/twitch/objects/stream_marker.rb
|
@@ -75,12 +79,18 @@ files:
|
|
75
79
|
- lib/twitch/objects/subscription_count.rb
|
76
80
|
- lib/twitch/objects/tag.rb
|
77
81
|
- lib/twitch/objects/user.rb
|
82
|
+
- lib/twitch/objects/user_color.rb
|
78
83
|
- lib/twitch/objects/video.rb
|
84
|
+
- lib/twitch/objects/vip.rb
|
79
85
|
- lib/twitch/resource.rb
|
86
|
+
- lib/twitch/resources/announcements.rb
|
87
|
+
- lib/twitch/resources/automod.rb
|
80
88
|
- lib/twitch/resources/badges.rb
|
81
89
|
- lib/twitch/resources/banned_events.rb
|
82
90
|
- lib/twitch/resources/banned_users.rb
|
91
|
+
- lib/twitch/resources/blocked_terms.rb
|
83
92
|
- lib/twitch/resources/channels.rb
|
93
|
+
- lib/twitch/resources/chat_messages.rb
|
84
94
|
- lib/twitch/resources/clips.rb
|
85
95
|
- lib/twitch/resources/custom_reward_redemptions.rb
|
86
96
|
- lib/twitch/resources/custom_rewards.rb
|
@@ -93,6 +103,7 @@ files:
|
|
93
103
|
- lib/twitch/resources/moderators.rb
|
94
104
|
- lib/twitch/resources/polls.rb
|
95
105
|
- lib/twitch/resources/predictions.rb
|
106
|
+
- lib/twitch/resources/raids.rb
|
96
107
|
- lib/twitch/resources/search.rb
|
97
108
|
- lib/twitch/resources/stream_markers.rb
|
98
109
|
- lib/twitch/resources/stream_schedule.rb
|
@@ -101,6 +112,8 @@ files:
|
|
101
112
|
- lib/twitch/resources/tags.rb
|
102
113
|
- lib/twitch/resources/users.rb
|
103
114
|
- lib/twitch/resources/videos.rb
|
115
|
+
- lib/twitch/resources/vips.rb
|
116
|
+
- lib/twitch/resources/whispers.rb
|
104
117
|
- lib/twitch/version.rb
|
105
118
|
- lib/twitchrb.rb
|
106
119
|
- twitchrb.gemspec
|
@@ -110,7 +123,7 @@ licenses:
|
|
110
123
|
metadata:
|
111
124
|
homepage_uri: https://deanpcmad.com
|
112
125
|
source_code_uri: https://github.com/deanpcmad/twitchrb
|
113
|
-
post_install_message:
|
126
|
+
post_install_message:
|
114
127
|
rdoc_options: []
|
115
128
|
require_paths:
|
116
129
|
- lib
|
@@ -126,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
139
|
version: '0'
|
127
140
|
requirements: []
|
128
141
|
rubygems_version: 3.3.7
|
129
|
-
signing_key:
|
142
|
+
signing_key:
|
130
143
|
specification_version: 4
|
131
144
|
summary: A Ruby library for interacting with the Twitch Helix API
|
132
145
|
test_files: []
|