Sha256: 8d02331f831b7812ee8b436a91fcd6f1d6759b5475a78b0018c31a2d80ed43c6

Contents?: true

Size: 921 Bytes

Versions: 7

Compression:

Stored size: 921 Bytes

Contents

module MatrixQQ
  class QQ
    # send group massage to other
    class ForwardGroup
      class << self
        attr_accessor :send_to
      end
      self.send_to = Hash.new { |h, k| h[k] = [] }

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

      def run
        return unless @info.is_a? Hash
        tunnel = Config[:tunnel][@info['group_id'].to_s]
        return if tunnel.nil?
        return unless tunnel[:type] == 'group'
        tunnel[:to].each_pair do |room, type|
          call_module(room, type)
        end
      end

      def call_module(room, type)
        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
    end # Forward

    QQ.group << ForwardGroup
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
matrix_qq-0.3.3 lib/matrix_qq/qq/forward_group/main.rb
matrix_qq-0.3.2 lib/matrix_qq/qq/forward_group/main.rb
matrix_qq-0.3.1 lib/matrix_qq/qq/forward_group/main.rb
matrix_qq-0.3.0 lib/matrix_qq/qq/forward_group/main.rb
matrix_qq-0.2.1 lib/matrix_qq/qq/forward_group/main.rb
matrix_qq-0.2.0 lib/matrix_qq/qq/forward_group/main.rb
matrix_qq-0.1.1 lib/matrix_qq/qq/forward_group/main.rb