Class: OPQ::QqObj

Inherits:
Object
  • Object
show all
Defined in:
lib/opqr/qqobj.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(qq, plugins) ⇒ QqObj

Returns a new instance of QqObj.



7
8
9
10
# File 'lib/opqr/qqobj.rb', line 7

def initialize(qq, plugins)
  @qq = qq
  @plugins = plugins
end

Instance Attribute Details

#pluginsObject

Returns the value of attribute plugins.



6
7
8
# File 'lib/opqr/qqobj.rb', line 6

def plugins
  @plugins
end

#qqObject

Returns the value of attribute qq.



6
7
8
# File 'lib/opqr/qqobj.rb', line 6

def qq
  @qq
end

Instance Method Details

#on_data_received(msg) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/opqr/qqobj.rb', line 11

def on_data_received(msg)
  msg_json = JSON.parse(msg)
  receive = OPQ::Msg.new(msg_json)
  @plugins.each do |p|
    # 1好友 2群组
    if receive.type == 1
      p.receive_qq(@qq, receive)
    elsif receive.type == 2 && receive.sender_uin != @qq && receive.msg_type != 732
      p.receive_group(@qq, receive)
    end
  end
end