twitchrb 1.2.2 → 1.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80e37cae23180ab0f9c0e5ba59691a10f306ee5440d99eea6805e355e30f6cb9
4
- data.tar.gz: 682c90dc5794062250bfde3ede6d20833a13667962ede478e60cd0f5c76e9b74
3
+ metadata.gz: 1269fdc61b940ec41b8dc926e407f7f33075998ad7ab488e191bb12e7f2926ee
4
+ data.tar.gz: 393eaef53b73443c32b2a26911acdfe45496d77ee0ce6f748daa61e8227a9fcc
5
5
  SHA512:
6
- metadata.gz: 7a00aa325114e5b7e15935ad7301618349deb0b66615e5599ca137adf38ac1feb1817e42777b4f0120da2d366271a16969d0436319aa1492e804a3df50bbd7f1
7
- data.tar.gz: c04351cf7d0bc5b7b14b270cf015c1722aaced8521154d2171b6acf040dbb0fc03125951451d5feecd98fdcac04078bc3f8ab338932e7c0f98ad57f77813f46a
6
+ metadata.gz: 97c97cf66f5fe20ccea0f39fdbc14721359c81f29ec14b8aab501da91f73b603b8d77296d01eb63c6225619828f112629312742a70fae91c55c1c086f0b989f6
7
+ data.tar.gz: d8d65949ae74ea874ab22c4d4e4ed39d26a5f80824254245e31a200e9067d8ac6c944d277bba087eefefceb6b93cafa863ba006f2e038fe0789cbf6f1fb8166c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twitchrb (1.2.2)
4
+ twitchrb (1.2.3)
5
5
  faraday (~> 2.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -317,7 +317,15 @@ These require an application OAuth access token.
317
317
  @client.raids.delete broadcaster_id: 123
318
318
  ```
319
319
 
320
+ ### Chat Messages
321
+
320
322
  ```ruby
323
+ # Send a chat message to a broadcaster's chat room
324
+ # Requires an app or user access token that includes user:write:chat then either user:bot or channel:bot
325
+ # sender_id must be the currently authenticated user
326
+ # reply_to is optional and is the UUID of the message to reply to
327
+ @client.chat_messages.create broadcaster_id: 123, sender_id: 321, message: "A test message", reply_to: "aabbcc"
328
+
321
329
  # Removes a single chat message from the broadcaster's chat room
322
330
  # Requires moderator:manage:chat_messages
323
331
  # moderator_id can be either the currently authenticated moderator or the broadcaster
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class ChatMessage < Object
3
+ end
4
+ end
@@ -1,6 +1,13 @@
1
1
  module Twitch
2
2
  class ChatMessagesResource < Resource
3
-
3
+
4
+ def create(broadcaster_id:, sender_id:, message:, reply_to: nil)
5
+ attrs = {broadcaster_id: broadcaster_id, sender_id: sender_id, message: message, reply_parent_message_id: reply_to}
6
+
7
+ response = post_request("chat/messages", body: attrs)
8
+ ChatMessage.new(response.body.dig("data")[0])
9
+ end
10
+
4
11
  # moderator_id must match the user in the OAuth token
5
12
  def delete(broadcaster_id:, moderator_id:, message_id:)
6
13
  delete_request("moderation/chat?broadcaster_id=#{broadcaster_id}&moderator_id=#{moderator_id}&message_id=#{message_id}")
@@ -15,9 +15,9 @@ module Twitch
15
15
  end
16
16
 
17
17
  body = response.body.dig("data")
18
- if body.count == 1
18
+ if id || name && body.count == 1
19
19
  Game.new body[0]
20
- elsif body.count > 1
20
+ elsif ids || names && body.count > 1
21
21
  Collection.from_response(response, type: Game)
22
22
  else
23
23
  return nil
@@ -15,9 +15,9 @@ module Twitch
15
15
  end
16
16
 
17
17
  body = response.body.dig("data")
18
- if body.count == 1
18
+ if id || username && body.count == 1
19
19
  User.new body[0]
20
- elsif body.count > 1
20
+ elsif ids || usernames && body.count > 1
21
21
  Collection.from_response(response, type: User)
22
22
  else
23
23
  return nil
@@ -1,3 +1,3 @@
1
1
  module Twitch
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.4"
3
3
  end
data/lib/twitch.rb CHANGED
@@ -85,5 +85,6 @@ module Twitch
85
85
  autoload :BlockedTerm, "twitch/objects/blocked_term"
86
86
  autoload :CharityCampaign, "twitch/objects/charity_campaign"
87
87
  autoload :Chatter, "twitch/objects/chatter"
88
+ autoload :ChatMessage, "twitch/objects/chat_message"
88
89
 
89
90
  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: 1.2.2
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Perry
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -57,6 +57,7 @@ files:
57
57
  - lib/twitch/objects/channel.rb
58
58
  - lib/twitch/objects/channel_editor.rb
59
59
  - lib/twitch/objects/charity_campaign.rb
60
+ - lib/twitch/objects/chat_message.rb
60
61
  - lib/twitch/objects/chatter.rb
61
62
  - lib/twitch/objects/clip.rb
62
63
  - lib/twitch/objects/custom_reward.rb