Class: MatrixQQ::QQ
- Inherits:
-
Object
- Object
- MatrixQQ::QQ
- Defined in:
- lib/matrix_qq/qq/qq.rb,
lib/matrix_qq/qq/log.rb,
lib/matrix_qq/qq/dbus.rb,
lib/matrix_qq/qq/send.rb,
lib/matrix_qq/qq/forward_group/main.rb,
lib/matrix_qq/qq/forward_friend/main.rb,
lib/matrix_qq/qq/forward_group/matrix.rb,
lib/matrix_qq/qq/forward_friend/matrix.rb
Defined Under Namespace
Modules: SendGroup Classes: DBus, ForwardFriend, ForwardGroup, Log
Constant Summary collapse
- SIGN =
i[ private group get_group_list event group_upload group_admin group_decrease group_increase friend_add friend_request join_request invite_request all unknow ].freeze
- CQ =
{ 'text' => ->(msg) { msg['data']['text'] }, 'face' => ->(msg) { "[QQ 表情:#{msg['data']['id']}]" }, 'bface' => ->(msg) { "[QQ 原创表情:#{msg['data']['id']}]" }, 'sface' => ->(msg) { "[QQ 小表情:#{msg['data']['id']}]" }, 'emoji' => ->(msg) { [msg['data']['id'].to_i].pack 'U' }, 'record' => ->(___) { '[语音]' }, 'image' => ->(msg) { msg['data']['url'] }, 'at' => ->(msg) { "@#{msg['data']['qq']} " }, 'rps' => ->(msg) { "[#{%w[石头 剪刀 布][msg['data']['type'] - 1]}]" }, 'dice' => ->(msg) { "[掷得 #{msg['data']['type']} 点]" }, 'shake' => ->(___) { '[窗口抖动]' }, 'music' => ->(msg) { "[音乐 #{msg['data'].to_json}]" }, 'share' => ->(msg) { "[分享 #{msg['data'].to_json}]" }, 'rich' => ->(___) { '' }, 'anonymous' => ->(___) { '[匿名消息:]' } }.freeze
Instance Attribute Summary collapse
-
#dbus ⇒ Object
readonly
Returns the value of attribute dbus.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#matrix_dbus ⇒ Object
Returns the value of attribute matrix_dbus.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dbus) ⇒ QQ
constructor
A new instance of QQ.
- #reg ⇒ Object
Constructor Details
#initialize(dbus) ⇒ QQ
Returns a new instance of QQ.
47 48 49 50 |
# File 'lib/matrix_qq/qq/qq.rb', line 47 def initialize(dbus) @dbus = DBus.new dbus reg end |
Instance Attribute Details
#dbus ⇒ Object (readonly)
Returns the value of attribute dbus.
44 45 46 |
# File 'lib/matrix_qq/qq/qq.rb', line 44 def dbus @dbus end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
44 45 46 |
# File 'lib/matrix_qq/qq/qq.rb', line 44 def info @info end |
#matrix_dbus ⇒ Object
Returns the value of attribute matrix_dbus.
45 46 47 |
# File 'lib/matrix_qq/qq/qq.rb', line 45 def matrix_dbus @matrix_dbus end |
Class Method Details
.cq_call(msg) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/matrix_qq/qq/qq.rb', line 65 def self.cq_call(msg) m = QQ::CQ[msg['type']] raise "Unknow type #{msg['type']}" if m.nil? m = m.call(msg) return '' if m.nil? m end |
Instance Method Details
#reg ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/matrix_qq/qq/qq.rb', line 52 def reg SIGN.each do |i| @dbus.obj.on_signal i.to_s do |json| info = JSON.parse json QQ.send(i).each do |func| MatrixQQ.log(func.name) do func.new(@dbus, @matrix_dbus, info.dup).run end end end end end |