matrix_qq 0.5.3 → 0.5.4

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
  SHA1:
3
- metadata.gz: a7f1ca69b9545bf36b84bb8be5884c5ed343669b
4
- data.tar.gz: 6759bda077e3d675238ca0602a0a885b7617d74e
3
+ metadata.gz: c29f625d98e417ccbcb15f76dc231e1cdbbc7543
4
+ data.tar.gz: e42689a5edb2b7d5fa9244a595c40c8273d5e9cf
5
5
  SHA512:
6
- metadata.gz: c6ded8ebfece05ae18d2f26d84ff59ab6db178642bfbbd24917ec96d39b0b558dddc1b35612c90cd6c996ffeefcc1d695f4f69b3cf1fb7f70249ff3aad2e2167
7
- data.tar.gz: 2369ef19762c5474749ef7c9366a72977024b3c3fbe0eb9454955a7b774b91f506d5c018339bb1cff8cedfd490fe0f9a85084e776ab61126ad74cf399cc4d1b2
6
+ metadata.gz: 53eedc6eaf07ed958e3665c567e1cbcf44a4225011a718b74048e3168533d022e6014fdf5542d84b5a3db277a99615b1f1464b0ebd9f9d3975f9ae8819b6d5ef
7
+ data.tar.gz: 17a29886324a8071383bf8ffc15190c20e1a3e1927619b421d4ccd9f165ef6bef18055118c009e4c83878b304be82aeb728afb280bdce73774a2502661dd1284
data/CHANGELOG.yaml CHANGED
@@ -1,5 +1,13 @@
1
1
  # Notice: Incompatible items start with `!`
2
2
 
3
+ master:
4
+ 0.5.4:
5
+ Feature:
6
+ - agree friend add request
7
+ - agree group invite request
8
+ - add log
9
+ Change:
10
+ - delete emoji code because cqhttp v3.0.1
3
11
  0.5.3:
4
12
  Fix:
5
13
  - example config
data/exe/matrix_qq CHANGED
@@ -32,13 +32,23 @@ end)
32
32
  end
33
33
  load config
34
34
 
35
+ LOG =
36
+ if ARGV.include? '-q'
37
+ open '/dev/null', 'w'
38
+ else
39
+ STDOUT
40
+ end
41
+
35
42
  session_bus = DBus::SessionBus.instance
36
43
 
37
44
  matrix = MatrixQQ::Matrix.new session_bus
45
+ LOG.puts 'Matrix inited'
38
46
  qq = MatrixQQ::QQ.new session_bus
47
+ LOG.puts 'QQ inited'
39
48
  matrix.qq_dbus = qq.dbus
40
49
  qq.matrix_dbus = matrix.dbus
41
50
 
42
51
  main = DBus::Main.new
43
52
  main << session_bus
53
+ LOG.puts 'Started'
44
54
  main.run
@@ -3,35 +3,6 @@ module MatrixQQ
3
3
  class Forward
4
4
  # send to qq group
5
5
  class Group
6
- Emoji = [
7
- *(0x0080..0x02AF),
8
- *(0x0300..0x03FF),
9
- *(0x0600..0x06FF),
10
- *(0x0C00..0x0C7F),
11
- *(0x1DC0..0x1DFF),
12
- *(0x1E00..0x1EFF),
13
- *(0x2000..0x209F),
14
- *(0x20D0..0x214F),
15
- *(0x2190..0x23FF),
16
- *(0x2460..0x25FF),
17
- *(0x2600..0x27EF),
18
- *(0x2900..0x29FF),
19
- *(0x2B00..0x2BFF),
20
- *(0x2C60..0x2C7F),
21
- *(0x2E00..0x2E7F),
22
- *(0x3000..0x303F),
23
- *(0xA490..0xA4CF),
24
- *(0xE000..0xF8FF),
25
- *(0xFE00..0xFE0F),
26
- *(0xFE30..0xFE4F),
27
- *(0x1F000..0x1F02F),
28
- *(0x1F0A0..0x1F0FF),
29
- *(0x1F100..0x1F64F),
30
- *(0x1F680..0x1F6FF),
31
- *(0x1F910..0x1F96B),
32
- *(0x1F980..0x1F9E0)
33
- ].freeze
34
-
35
6
  def initialize(dbus, matrix, info, room)
36
7
  @dbus = dbus
37
8
  @info = info
@@ -46,19 +17,7 @@ module MatrixQQ
46
17
  sender = user @info['sender']
47
18
  sender, body = user_bot body if user_bot? body
48
19
  message = format_matrix_message(body, sender, type)
49
- MatrixQQ::QQ::SendGroup.array @matrix, @room, emoji(message)
50
- end
51
-
52
- def emoji(msg)
53
- return { type: 'text', data: { text: msg } } if (msg & Emoji).empty?
54
- msg.each_codepoint.inject([]) do |obj, code|
55
- obj <<
56
- if Emoji.include? code
57
- { type: 'emoji', data: { id: code.to_s } }
58
- else
59
- { type: 'text', data: { text: [code].pack('U') } }
60
- end
61
- end
20
+ MatrixQQ::QQ::SendGroup.text @matrix, @room, message
62
21
  end
63
22
 
64
23
  def format_matrix_message(msg, name, type = 'm.text')
@@ -0,0 +1,30 @@
1
+ module MatrixQQ
2
+ class QQ
3
+ class AgreeFriend
4
+ def initialize(dbus, _, info)
5
+ @dbus = dbus
6
+ @info = info
7
+ end
8
+
9
+ def run
10
+ return unless @info.is_a? Hash
11
+ @dbus.set_friend_add_request flag: @info['flag']
12
+ end
13
+ end # AgreeFriend
14
+
15
+ class AgreeGroup
16
+ def initialize(dbus, _, info)
17
+ @dbus = dbus
18
+ @info = info
19
+ end
20
+
21
+ def run
22
+ return unless @info.is_a? Hash
23
+ @dbus.set_group_add_request flag: @info['flag'], type: 'invite'
24
+ end
25
+ end # AgreeGroup
26
+
27
+ QQ.friend_request << AgreeFriend
28
+ QQ.invite_request << AgreeGroup
29
+ end
30
+ end
@@ -28,7 +28,6 @@ module MatrixQQ
28
28
  'face' => ->(msg) { "[QQ 表情:#{msg['data']['id']}]" },
29
29
  'bface' => ->(msg) { "[QQ 原创表情:#{msg['data']['id']}]" },
30
30
  'sface' => ->(msg) { "[QQ 小表情:#{msg['data']['id']}]" },
31
- 'emoji' => ->(msg) { [msg['data']['id'].to_i].pack 'U' },
32
31
  'record' => ->(___) { '[语音]' },
33
32
  'image' => ->(msg) { msg['data']['url'] },
34
33
  'at' => ->(msg) { "@#{msg['data']['qq']} " },
@@ -2,6 +2,7 @@ require 'matrix_qq/qq/dbus'
2
2
  require 'matrix_qq/qq/qq'
3
3
 
4
4
  require 'matrix_qq/qq/log'
5
+ require 'matrix_qq/qq/agree'
5
6
 
6
7
  require 'matrix_qq/qq/send'
7
8
 
@@ -1,3 +1,3 @@
1
1
  module MatrixQQ
2
- VERSION = '0.5.3'.freeze
2
+ VERSION = '0.5.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matrix_qq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - 71e6fd52
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-05 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,6 +136,7 @@ files:
136
136
  - lib/matrix_qq/matrix/matrix.rb
137
137
  - lib/matrix_qq/matrix/require.rb
138
138
  - lib/matrix_qq/matrix/send.rb
139
+ - lib/matrix_qq/qq/agree.rb
139
140
  - lib/matrix_qq/qq/dbus.rb
140
141
  - lib/matrix_qq/qq/forward_friend/main.rb
141
142
  - lib/matrix_qq/qq/forward_friend/matrix.rb