matrix_qq 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.yaml +10 -0
- data/lib/matrix_qq/qq/forward_friend/main.rb +52 -0
- data/lib/matrix_qq/qq/forward_friend/matrix.rb +34 -0
- data/lib/matrix_qq/qq/forward_group/main.rb +3 -4
- data/lib/matrix_qq/qq/require.rb +3 -0
- data/lib/matrix_qq/utils.rb +1 -1
- data/lib/matrix_qq/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e8e2d63bc458ef9fe56fe6e75b0e933a8b3c337
|
4
|
+
data.tar.gz: af4d419663e04cad318b19fe834388d6a70d730d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b884e630c813d6f0f25fe884ea45dd76eb83a606b152dd1958069ec901095fbcff1f60fd714f9e52d5ed31d61dbc9f220c7ccb5ba0a86e7f1e73fed2dbc248b0
|
7
|
+
data.tar.gz: a5e2f6acc60bd3dd0d49abc1e87edf6015aee9c9b87be77ad6f82d2b6379acb964604b7ca32f3654d9af170ce164e847b65dcc11b0b855158d670bef181eede7
|
data/CHANGELOG.yaml
CHANGED
@@ -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
|
-
|
19
|
-
run_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 #
|
48
|
+
end # ForwardGroup
|
50
49
|
|
51
50
|
QQ.group << ForwardGroup
|
52
51
|
end
|
data/lib/matrix_qq/qq/require.rb
CHANGED
data/lib/matrix_qq/utils.rb
CHANGED
data/lib/matrix_qq/version.rb
CHANGED
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
|
+
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
|