Class: MatrixQQ::Matrix

Inherits:
Object
  • Object
show all
Defined in:
lib/matrix_qq/matrix/log.rb,
lib/matrix_qq/matrix/dbus.rb,
lib/matrix_qq/matrix/hack.rb,
lib/matrix_qq/matrix/send.rb,
lib/matrix_qq/matrix/matrix.rb,
lib/matrix_qq/matrix/forward/main.rb,
lib/matrix_qq/matrix/forward/group.rb

Defined Under Namespace

Modules: Hack, Send Classes: DBus, Forward, Log

Constant Summary collapse

SIGN =
%i[
  all
  account_data
  to_device
  presence
  rooms
  leave
  join
  invite
  device_lists
  changed
  left
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dbus) ⇒ Matrix

Returns a new instance of Matrix.



25
26
27
28
# File 'lib/matrix_qq/matrix/matrix.rb', line 25

def initialize(dbus)
  @dbus = DBus.new dbus
  reg
end

Instance Attribute Details

#dbusObject (readonly)

Returns the value of attribute dbus.



22
23
24
# File 'lib/matrix_qq/matrix/matrix.rb', line 22

def dbus
  @dbus
end

#infoObject (readonly)

Returns the value of attribute info.



22
23
24
# File 'lib/matrix_qq/matrix/matrix.rb', line 22

def info
  @info
end

#qq_dbusObject

Returns the value of attribute qq_dbus.



23
24
25
# File 'lib/matrix_qq/matrix/matrix.rb', line 23

def qq_dbus
  @qq_dbus
end

Instance Method Details

#hack(i, info) ⇒ Object



43
44
45
46
# File 'lib/matrix_qq/matrix/matrix.rb', line 43

def hack(i, info)
  Hack.list.each { |h| info = h.call(@dbus, info, i) }
  info
end

#regObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/matrix_qq/matrix/matrix.rb', line 30

def reg
  SIGN.each do |i|
    @dbus.obj.on_signal i.to_s do |json|
      info = hack i, JSON.parse(json)
      Matrix.send(i).each do |func|
        MatrixQQ.log(func.name) do
          func.new(@dbus, @qq_dbus, info.dup).run
        end
      end
    end
  end
end