matrix_qq 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b10cb473c23ae57054f29f317828d51d3e0cc3a0
4
- data.tar.gz: 84d52dfe120fd743b2bd54e12699ba07a478c97e
3
+ metadata.gz: 1e8e2d63bc458ef9fe56fe6e75b0e933a8b3c337
4
+ data.tar.gz: af4d419663e04cad318b19fe834388d6a70d730d
5
5
  SHA512:
6
- metadata.gz: 364aae41c69bc800fff31dfe978b3fffaae1d4343b6a0370d4d494a50b1dcd85d428891dce95bd6fe7eb8af3e33fd6293d9c2d541c1a024e2f4a877f29820744
7
- data.tar.gz: cad73b838a627235490481f37284c8cfa4440b8a1d640119576f9cbbd2073453e6987871698f9f9ca1a7941fc971db10321815eaa279020eb07d6fb93afff93a
6
+ metadata.gz: b884e630c813d6f0f25fe884ea45dd76eb83a606b152dd1958069ec901095fbcff1f60fd714f9e52d5ed31d61dbc9f220c7ccb5ba0a86e7f1e73fed2dbc248b0
7
+ data.tar.gz: a5e2f6acc60bd3dd0d49abc1e87edf6015aee9c9b87be77ad6f82d2b6379acb964604b7ca32f3654d9af170ce164e847b65dcc11b0b855158d670bef181eede7
data/CHANGELOG.yaml CHANGED
@@ -1,5 +1,15 @@
1
1
  # Notice: Incompatible items start with `!`
2
2
 
3
+ 0.5.0:
4
+ Feature:
5
+ - friend to matrix
6
+ Fix:
7
+ - friend forword
8
+ - group forword
9
+ - intercept logic
10
+ - name
11
+ - Friend call Group mudule
12
+ - wrong speel
3
13
  0.4.0:
4
14
  Feature:
5
15
  - msgtype rich
@@ -0,0 +1,52 @@
1
+ module MatrixQQ
2
+ class QQ
3
+ class ForwardFriend
4
+ class << self
5
+ attr_accessor :send_to
6
+ end
7
+ self.send_to = Hash.new { |h, k| h[k] = [] }
8
+
9
+ def initialize(dbus, matrix, info)
10
+ @dbus = dbus
11
+ @info = info
12
+ @matrix = matrix
13
+ end
14
+
15
+ def run
16
+ return unless @info.is_a? Hash
17
+ return if run_exact
18
+ run_all
19
+ end
20
+
21
+ def run_exact
22
+ tunnel = Config[:tunnel][@info['user_id'].to_s]
23
+ return false if tunnel.nil?
24
+ return false unless tunnel[:type] == 'friend'
25
+ tunnel[:to].each_pair do |room, type|
26
+ call_module room, type
27
+ end
28
+ MatrixQQ.intercept? tunnel
29
+ end
30
+
31
+ def run_all
32
+ tunnel = Config[:tunnel]['friend']
33
+ return if tunnel.nil?
34
+ return unless tunnel[:type] == 'all'
35
+ tunnel[:to].each_pair do |room, type|
36
+ call_module room, type, print_sender: true
37
+ end
38
+ end
39
+
40
+ def call_module(room, type, hackin = {})
41
+ info = @info.merge hackin
42
+ ForwardFriend.send_to[type.to_s].each do |func|
43
+ puts "Start #{func.name}" if $VERBOSE
44
+ func.new(@dbus, @matrix, info, room).run
45
+ puts "End #{func.name}" if $VERBOSE
46
+ end
47
+ end
48
+ end # ForwardFriend
49
+
50
+ QQ.private << ForwardFriend
51
+ end
52
+ end
@@ -0,0 +1,34 @@
1
+ module MatrixQQ
2
+ class QQ
3
+ class ForwardFriend
4
+ class Matrix
5
+ def initialize(dbus, matrix, info, room)
6
+ @dbus = dbus
7
+ @info = info
8
+ @matrix = matrix
9
+ @room = room
10
+ end
11
+
12
+ def run
13
+ msg = message @info['message']
14
+ sender = "[#{user @info['user_id']}] " if @info['print_sender']
15
+ MatrixQQ::Matrix::Send.text \
16
+ @matrix, @room,
17
+ "#{sender}#{msg}"
18
+ end
19
+
20
+ def message(messages)
21
+ messages.inject('') do |obj, msg|
22
+ obj + QQ.cq_call(msg)
23
+ end
24
+ end
25
+
26
+ def user(user)
27
+ @dbus.get_stranger_info(user_id: user)['nickname']
28
+ end
29
+ end # Matrix
30
+
31
+ ForwardFriend.send_to['matrix'] << Matrix
32
+ end # ForwardFriend
33
+ end # QQ
34
+ end
@@ -1,6 +1,5 @@
1
1
  module MatrixQQ
2
2
  class QQ
3
- # send group massage to other
4
3
  class ForwardGroup
5
4
  class << self
6
5
  attr_accessor :send_to
@@ -15,8 +14,8 @@ module MatrixQQ
15
14
 
16
15
  def run
17
16
  return unless @info.is_a? Hash
18
- all = run_exact room, value
19
- run_all room, value if all
17
+ return if run_exact
18
+ run_all
20
19
  end
21
20
 
22
21
  def run_exact
@@ -46,7 +45,7 @@ module MatrixQQ
46
45
  puts "End #{func.name}" if $VERBOSE
47
46
  end
48
47
  end
49
- end # Forward
48
+ end # ForwardGroup
50
49
 
51
50
  QQ.group << ForwardGroup
52
51
  end
@@ -7,3 +7,6 @@ require 'matrix_qq/qq/send'
7
7
 
8
8
  require 'matrix_qq/qq/forward_group/main'
9
9
  require 'matrix_qq/qq/forward_group/matrix'
10
+
11
+ require 'matrix_qq/qq/forward_friend/main'
12
+ require 'matrix_qq/qq/forward_friend/matrix'
@@ -2,7 +2,7 @@ module MatrixQQ
2
2
  class << self
3
3
  def intercept?(tunnel)
4
4
  i = tunnel[:intercept]
5
- return true if i.nil?
5
+ return false if i.nil?
6
6
  return true if i
7
7
  false
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module MatrixQQ
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matrix_qq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 71e6fd52
@@ -137,6 +137,8 @@ files:
137
137
  - lib/matrix_qq/matrix/require.rb
138
138
  - lib/matrix_qq/matrix/send.rb
139
139
  - lib/matrix_qq/qq/dbus.rb
140
+ - lib/matrix_qq/qq/forward_friend/main.rb
141
+ - lib/matrix_qq/qq/forward_friend/matrix.rb
140
142
  - lib/matrix_qq/qq/forward_group/main.rb
141
143
  - lib/matrix_qq/qq/forward_group/matrix.rb
142
144
  - lib/matrix_qq/qq/log.rb