khl 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/README.md +53 -0
- data/lib/khl/http/asset.rb +19 -0
- data/lib/khl/http/badge.rb +20 -0
- data/lib/khl/http/base.rb +101 -0
- data/lib/khl/http/blacklist.rb +41 -0
- data/lib/khl/http/channel.rb +58 -0
- data/lib/khl/http/channel_role.rb +50 -0
- data/lib/khl/http/channel_user.rb +22 -0
- data/lib/khl/http/client.rb +78 -0
- data/lib/khl/http/direct_message.rb +85 -0
- data/lib/khl/http/game.rb +59 -0
- data/lib/khl/http/gateway.rb +19 -0
- data/lib/khl/http/guild.rb +70 -0
- data/lib/khl/http/guild_emoji.rb +46 -0
- data/lib/khl/http/guild_mute.rb +38 -0
- data/lib/khl/http/guild_role.rb +70 -0
- data/lib/khl/http/intimacy.rb +29 -0
- data/lib/khl/http/invite.rb +43 -0
- data/lib/khl/http/message.rb +92 -0
- data/lib/khl/http/response.rb +69 -0
- data/lib/khl/http/user.rb +32 -0
- data/lib/khl/http/user_chat.rb +42 -0
- data/lib/khl/version.rb +5 -0
- data/lib/khl/web_socket/client.rb +151 -0
- data/lib/khl/web_socket/message.rb +54 -0
- data/lib/khl.rb +6 -0
- metadata +108 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KHL
|
4
|
+
module WebSocket
|
5
|
+
class Message
|
6
|
+
TYPES = %i[
|
7
|
+
event
|
8
|
+
hello
|
9
|
+
ping
|
10
|
+
pong
|
11
|
+
resume
|
12
|
+
reconnect
|
13
|
+
resume_ack
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
attr_accessor :type, :data, :sn
|
17
|
+
|
18
|
+
def self.parse(raw)
|
19
|
+
return unless raw
|
20
|
+
|
21
|
+
data = JSON.parse(raw)
|
22
|
+
message = Message.new
|
23
|
+
message.type = TYPES[data["s"]]
|
24
|
+
message.data = data["d"]
|
25
|
+
message.sn = data["sn"]
|
26
|
+
message
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(type: nil, data: nil, sn: nil)
|
30
|
+
@type = type
|
31
|
+
@data = data
|
32
|
+
@sn = sn
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_h
|
36
|
+
{
|
37
|
+
s: TYPES.index(type),
|
38
|
+
d: data,
|
39
|
+
sn: sn
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_json
|
44
|
+
to_h.to_json
|
45
|
+
end
|
46
|
+
|
47
|
+
TYPES.each do |type|
|
48
|
+
define_method("#{type}?") do
|
49
|
+
@type == type
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/khl.rb
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: khl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dounx
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 7.0.2.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '7.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 7.0.2.3
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: faye-websocket
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.11.1
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.11.1
|
47
|
+
description: Ruby SDK for 开黑啦
|
48
|
+
email:
|
49
|
+
- imdounx@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- CHANGELOG.md
|
55
|
+
- README.md
|
56
|
+
- lib/khl.rb
|
57
|
+
- lib/khl/http/asset.rb
|
58
|
+
- lib/khl/http/badge.rb
|
59
|
+
- lib/khl/http/base.rb
|
60
|
+
- lib/khl/http/blacklist.rb
|
61
|
+
- lib/khl/http/channel.rb
|
62
|
+
- lib/khl/http/channel_role.rb
|
63
|
+
- lib/khl/http/channel_user.rb
|
64
|
+
- lib/khl/http/client.rb
|
65
|
+
- lib/khl/http/direct_message.rb
|
66
|
+
- lib/khl/http/game.rb
|
67
|
+
- lib/khl/http/gateway.rb
|
68
|
+
- lib/khl/http/guild.rb
|
69
|
+
- lib/khl/http/guild_emoji.rb
|
70
|
+
- lib/khl/http/guild_mute.rb
|
71
|
+
- lib/khl/http/guild_role.rb
|
72
|
+
- lib/khl/http/intimacy.rb
|
73
|
+
- lib/khl/http/invite.rb
|
74
|
+
- lib/khl/http/message.rb
|
75
|
+
- lib/khl/http/response.rb
|
76
|
+
- lib/khl/http/user.rb
|
77
|
+
- lib/khl/http/user_chat.rb
|
78
|
+
- lib/khl/version.rb
|
79
|
+
- lib/khl/web_socket/client.rb
|
80
|
+
- lib/khl/web_socket/message.rb
|
81
|
+
homepage: https://github.com/DessertShop/KHL
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata:
|
85
|
+
bug_tracker_uri: https://github.com/DessertShop/KHL/issues
|
86
|
+
changelog_uri: https://github.com/DessertShop/KHL/blob/master/CHANGELOG.md
|
87
|
+
documentation_uri: https://github.com/DessertShop/KHL/blob/master/README.md
|
88
|
+
source_code_uri: https://github.com/DessertShop/KHL
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.7.0
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubygems_version: 3.2.33
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Ruby SDK for 开黑啦
|
108
|
+
test_files: []
|