khl 1.2.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3110943f00d66a4139d82f1f13798cde8f4ffddc0462cffeb3c47c5e131a2b47
4
- data.tar.gz: bc8cb50c6876fbbc769667525f84bcbda3c2a9aa1d1e76bfdb00a2525a443ea8
3
+ metadata.gz: dada5b7c211f7c1b21ca9e5221f47e50d21e53817e36af0c93376955caa8a1ea
4
+ data.tar.gz: cf24e949bb192a9db50c0c98daee9ae6f27009244b7039e94f5b5d68f6f55cbc
5
5
  SHA512:
6
- metadata.gz: 8b4be1d65e2cb54e3d1b1a762253bc2fa3578bf448b056d9905edc7a0823c216802a857122b6904b93484f016585b2c5d5e314500b38ad0839765526ac6f0a43
7
- data.tar.gz: 99916625ffb6cb60f9613785167cae2209ad6e0f9f61af09a2f22e4d84605d4041aefaf0d6630612bb45adc22f6cb01881e13debe15cb1be5b4701596e36d480
6
+ metadata.gz: 95705f39d775096a4fb9addda311e0f72ce7b032f4a304c96072f4fa5286d02ae2fdd30f9aed37a702d1ddb4131539a1d221851a93e95dde47577a61473b7d9c
7
+ data.tar.gz: e85ae914fec3221a167199453aadba3d77b0677e29bbae306373c422f47352911127724c8fc4ce40015206f5041d8da9a78ccbbbf0ae0b001d0d62b1ebec8905
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 1.4.0 - 2022-04-18
2
+
3
+ * Rename KHL::HTTP::Response#error? to KHL::HTTP::Response#failed?
4
+
5
+ ### 1.3.0 - 2022-04-18
6
+
7
+ * Remove KHL::Event
8
+
9
+ ### 1.2.1 - 2022-04-18
10
+
11
+ * Add hash support for KHL::Message.parse
12
+
1
13
  ### 1.2.0 - 2022-04-08
2
14
 
3
15
  * Fix 开黑啦 Webhook API
@@ -48,7 +48,7 @@ module KHL
48
48
  http_code == 200 && code.zero?
49
49
  end
50
50
 
51
- def error?
51
+ def failed?
52
52
  !success?
53
53
  end
54
54
 
data/lib/khl/message.rb CHANGED
@@ -3,8 +3,6 @@
3
3
  require "active_support/core_ext/hash/indifferent_access"
4
4
  require "active_support/hash_with_indifferent_access"
5
5
 
6
- require_relative "event"
7
-
8
6
  module KHL
9
7
  class Message
10
8
  TYPES = %i[
@@ -22,14 +20,14 @@ module KHL
22
20
  def self.parse(raw)
23
21
  return unless raw
24
22
 
25
- data = JSON.parse(raw)
23
+ data = raw.is_a?(String) ? JSON.parse(raw) : raw
26
24
  data = ActiveSupport::HashWithIndifferentAccess.new(data)
27
25
 
28
- message = Message.new
29
- message.type = TYPES[data[:s]]
30
- message.data = data[:d]
31
- message.sn = data[:sn]
32
- message
26
+ Message.new(
27
+ type: TYPES[data[:s]],
28
+ data: data[:d],
29
+ sn: data[:sn]
30
+ )
33
31
  end
34
32
 
35
33
  def initialize(type: nil, data: nil, sn: nil)
@@ -38,12 +36,6 @@ module KHL
38
36
  @sn = sn
39
37
  end
40
38
 
41
- def event
42
- return unless event?
43
-
44
- Event.new(@data)
45
- end
46
-
47
39
  def to_h
48
40
  ActiveSupport::HashWithIndifferentAccess.new(
49
41
  s: TYPES.index(type),
data/lib/khl/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KHL
4
- VERSION = "1.2.0"
4
+ VERSION = "1.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: khl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dounx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-08 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -54,7 +54,6 @@ files:
54
54
  - CHANGELOG.md
55
55
  - README.md
56
56
  - lib/khl.rb
57
- - lib/khl/event.rb
58
57
  - lib/khl/http/asset.rb
59
58
  - lib/khl/http/badge.rb
60
59
  - lib/khl/http/base.rb
@@ -103,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
102
  - !ruby/object:Gem::Version
104
103
  version: '0'
105
104
  requirements: []
106
- rubygems_version: 3.3.10
105
+ rubygems_version: 3.3.11
107
106
  signing_key:
108
107
  specification_version: 4
109
108
  summary: Ruby SDK for 开黑啦
data/lib/khl/event.rb DELETED
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/core_ext/hash/indifferent_access"
4
- require "active_support/hash_with_indifferent_access"
5
-
6
- module KHL
7
- class Event
8
- attr_accessor :channel_type, :type, :target_id, :author_id, :content, :msg_id, :msg_timestamp, :nonce, :extra
9
-
10
- def initialize(params = {})
11
- params = ActiveSupport::HashWithIndifferentAccess.new(params)
12
-
13
- @channel_type = params[:channel_type]
14
- @type = params[:type]
15
- @target_id = params[:target_id]
16
- @author_id = params[:author_id]
17
- @content = params[:content]
18
- @msg_id = params[:msg_id]
19
- @msg_timestamp = params[:msg_timestamp]
20
- @nonce = params[:nonce]
21
- @extra = params[:extra]
22
- end
23
- end
24
- end