CQHTTP 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/cqhttp-dbus +64 -14
  3. data/lib/CQHTTP/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff7ce3959ce81bec0e5cb087fd9dd4c36cd6a429
4
- data.tar.gz: 64c650dab1a39f0d7151449f0a24d189aebc232e
3
+ metadata.gz: db0b0a77276f93d3b81abb0fad47c050c7fe4d5c
4
+ data.tar.gz: 22e17482ba89fcaba487c81a16b3d40153e7112b
5
5
  SHA512:
6
- metadata.gz: 5a39b9aa330a92840ca83ccf0c9450ff9b0d077934ad1862a32137ec06ea87d49a401cf43eb35c13e6e1f53ad88f598ca26af2021e9b2fa620b44b10a6671e8c
7
- data.tar.gz: 047b48e7f38bfe5204bb4a3439aad10007775ce1c6e9226dc5af8709b63f6ff719039a3fc5a19ba2fe383102bcfc1f95cbd4377374ac9700e46de4bb7922352d
6
+ metadata.gz: 184000c2b7eb45220139af5bb2a64a5e90412ad67cbc3ef8a144ebda343fb7953982a753063e5a9f8b1302e0b27028d70d0f9e63aa4179cf953b79ee45483dba
7
+ data.tar.gz: 96a9840f5d89175f6def2ebfb302435f1f68584837b3b2e901a2cd6d8bab7a5ed3ec2ea87e004192fe8a7f85921ec8a8280a7dae0a9f03c612d047bfd8116d9a
data/exe/cqhttp-dbus CHANGED
@@ -16,7 +16,19 @@ class CQHTTP2DBus < DBus::Object
16
16
  end
17
17
 
18
18
  dbus_signal :message, 'message_type:s, json:s'
19
+ %i[private group get_group_list].each do |i|
20
+ dbus_signal i, 'json:s'
21
+ end
19
22
  dbus_signal :event, 'event:s, json:s'
23
+ %i[
24
+ group_upload
25
+ group_admin
26
+ group_decrease
27
+ group_increase
28
+ friend_add
29
+ ].each do
30
+ dbus_signal i, 'json:s'
31
+ end
20
32
  dbus_signal :friend_request, 'json:s'
21
33
  dbus_signal :join_request, 'json:s'
22
34
  dbus_signal :invite_request, 'json:s'
@@ -25,27 +37,65 @@ class CQHTTP2DBus < DBus::Object
25
37
  end
26
38
  end
27
39
 
28
- def cqhttp2dbus(c, obj)
29
- j = c.json
30
- obj.all j.to_json
31
- case j['post_type']
32
- when 'message' then obj.message j['message_type'], j.to_json
33
- when 'event' then obj.event j['event'], j.to_json
34
- when 'request'
35
- case j['request_type']
36
- when 'friend' then obj.friend_request j.to_json
40
+ # case signal
41
+ class Case
42
+ def initialize(info, obj)
43
+ @info = info
44
+ @obj = obj
45
+ @json = gen_json
46
+ end
47
+
48
+ def gen_json
49
+ JSON.pretty_generate @info
50
+ end
51
+
52
+ def send_json(name)
53
+ @obj.send name, @json
54
+ end
55
+
56
+ def unknow
57
+ @obj.send_json :unknow
58
+ end
59
+
60
+ def run
61
+ send_json :all
62
+ case @info['post_type']
63
+ when 'message' then message
64
+ when 'event' then event
65
+ when 'request' then request
66
+ else unknow
67
+ end
68
+ end
69
+
70
+ def message
71
+ @obj.message @info['message_type'], @json
72
+ send_json @info['message_type']
73
+ end
74
+
75
+ def event
76
+ @obj.event @info['event'], @json
77
+ send_json @info['event']
78
+ end
79
+
80
+ def request
81
+ case @info['request_type']
82
+ when 'friend' then send_json :friend_request
37
83
  when 'group'
38
84
  case j['sub_type']
39
- when 'add' then obj.join_request j.to_json
40
- when 'invite' then obj.invite_request j.to_json
41
- else obj.unknow j.to_json
85
+ when 'add' then send_json :join_request
86
+ when 'invite' then send_json :invite_request
87
+ else unknow
42
88
  end
43
- else obj.unknow j.to_json
89
+ else unknow
44
90
  end
45
- else obj.unknow j.to_json
46
91
  end
47
92
  end
48
93
 
94
+ def cqhttp2dbus(c, obj)
95
+ j = c.json
96
+ Case.new(j, obj).run
97
+ end
98
+
49
99
  bus = DBus::SessionBus.instance
50
100
  service = bus.request_service 'org.dastudio.qq'
51
101
  obj = CQHTTP2DBus.new '/org/dastudio/qq'
@@ -1,3 +1,3 @@
1
1
  module CQHTTP
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CQHTTP
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 71e6fd52