Class: MatrixQQ::QQ::ForwardGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/matrix_qq/qq/forward_group/main.rb,
lib/matrix_qq/qq/forward_group/matrix.rb

Defined Under Namespace

Classes: Matrix

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dbus, matrix, info) ⇒ ForwardGroup

Returns a new instance of ForwardGroup.



9
10
11
12
13
# File 'lib/matrix_qq/qq/forward_group/main.rb', line 9

def initialize(dbus, matrix, info)
  @dbus = dbus
  @info = info
  @matrix = matrix
end

Class Attribute Details

.send_toObject

Returns the value of attribute send_to.



5
6
7
# File 'lib/matrix_qq/qq/forward_group/main.rb', line 5

def send_to
  @send_to
end

Instance Method Details

#call_module(room, type, hackin = {}) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/matrix_qq/qq/forward_group/main.rb', line 40

def call_module(room, type, hackin = {})
  info = @info.merge hackin
  ForwardGroup.send_to[type.to_s].each do |func|
    puts "Start #{func.name}" if $VERBOSE
    func.new(@dbus, @matrix, info, room).run
    puts "End #{func.name}" if $VERBOSE
  end
end

#runObject



15
16
17
18
19
# File 'lib/matrix_qq/qq/forward_group/main.rb', line 15

def run
  return unless @info.is_a? Hash
  return if run_exact
  run_all
end

#run_allObject



31
32
33
34
35
36
37
38
# File 'lib/matrix_qq/qq/forward_group/main.rb', line 31

def run_all
  tunnel = Config[:tunnel]['group']
  return if tunnel.nil?
  return unless tunnel[:type] == 'all'
  tunnel[:to].each_pair do |room, type|
    call_module room, type, print_room: true
  end
end

#run_exactObject



21
22
23
24
25
26
27
28
29
# File 'lib/matrix_qq/qq/forward_group/main.rb', line 21

def run_exact
  tunnel = Config[:tunnel][@info['group_id'].to_s]
  return false if tunnel.nil?
  return false unless tunnel[:type] == 'group'
  tunnel[:to].each_pair do |room, type|
    call_module room, type
  end
  MatrixQQ.intercept? tunnel
end