Class: MatrixQQ::Matrix::Forward
- Inherits:
-
Object
- Object
- MatrixQQ::Matrix::Forward
- Defined in:
- lib/matrix_qq/matrix/forward/main.rb,
lib/matrix_qq/matrix/forward/group.rb
Overview
send matrix massage to other
Defined Under Namespace
Classes: Group
Class Attribute Summary collapse
-
.send_to ⇒ Object
Returns the value of attribute send_to.
Instance Method Summary collapse
- #call_module(event, room, type) ⇒ Object
- #each_event(events, tunnel, hackin = {}) ⇒ Object
- #exist(forword) ⇒ Object
-
#initialize(dbus, qq, info) ⇒ Forward
constructor
A new instance of Forward.
- #run ⇒ Object
- #run_all(room, value) ⇒ Object
- #run_exact(room, value) ⇒ Object
Constructor Details
#initialize(dbus, qq, info) ⇒ Forward
Returns a new instance of Forward.
10 11 12 13 14 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 10 def initialize(dbus, qq, info) @dbus = dbus @info = info @qq = qq end |
Class Attribute Details
.send_to ⇒ Object
Returns the value of attribute send_to.
6 7 8 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 6 def send_to @send_to end |
Instance Method Details
#call_module(event, room, type) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 54 def call_module(event, room, type) Forward.send_to[type.to_s].each do |func| puts "Start #{func.name}" if $VERBOSE func.new(@dbus, @qq, event, room).run puts "End #{func.name}" if $VERBOSE end end |
#each_event(events, tunnel, hackin = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 43 def each_event(events, tunnel, hackin = {}) events.each do |event| next unless event['type'] == 'm.room.message' next if exist event['content']['forword'] event.merge!(hackin) tunnel[:to].each_pair do |to_room, type| call_module(event, to_room, type) end end end |
#exist(forword) ⇒ Object
62 63 64 65 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 62 def exist(forword) return false if forword.nil? !forword end |
#run ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 16 def run return unless @info.is_a? Hash @info.each_pair do |room, value| all = run_exact room, value run_all room, value if all end end |
#run_all(room, value) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 32 def run_all(room, value) tunnel = Config[:tunnel]['matrix'] return if tunnel.nil? return unless tunnel[:type] == 'all' each_event \ value['timeline']['events'], tunnel, print_room: true, send_room: room end |
#run_exact(room, value) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/matrix_qq/matrix/forward/main.rb', line 24 def run_exact(room, value) tunnel = Config[:tunnel][room] return false if tunnel.nil? return false unless tunnel[:type] == 'matrix' each_event value['timeline']['events'], tunnel MatrixQQ.intercept? tunnel end |