khl 1.2.0 → 1.4.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/CHANGELOG.md +12 -0
- data/lib/khl/http/response.rb +1 -1
- data/lib/khl/message.rb +6 -14
- data/lib/khl/version.rb +1 -1
- metadata +3 -4
- data/lib/khl/event.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dada5b7c211f7c1b21ca9e5221f47e50d21e53817e36af0c93376955caa8a1ea
|
4
|
+
data.tar.gz: cf24e949bb192a9db50c0c98daee9ae6f27009244b7039e94f5b5d68f6f55cbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/khl/http/response.rb
CHANGED
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
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.
|
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-
|
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.
|
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
|