Class: MatrixQQ::QQ::ForwardGroup::Matrix
- Inherits:
-
Object
- Object
- MatrixQQ::QQ::ForwardGroup::Matrix
- Defined in:
- lib/matrix_qq/qq/forward_group/matrix.rb
Overview
send to matrix
Instance Method Summary collapse
-
#initialize(dbus, matrix, info, room) ⇒ Matrix
constructor
A new instance of Matrix.
- #message(messages) ⇒ Object
- #run ⇒ Object
- #user(user, group_id = nil) ⇒ Object
Constructor Details
#initialize(dbus, matrix, info, room) ⇒ Matrix
Returns a new instance of Matrix.
6 7 8 9 10 11 |
# File 'lib/matrix_qq/qq/forward_group/matrix.rb', line 6 def initialize(dbus, matrix, info, room) @dbus = dbus @info = info @matrix = matrix @room = room end |
Instance Method Details
#message(messages) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/matrix_qq/qq/forward_group/matrix.rb', line 19 def () .inject('') do |obj, msg| obj + case msg['type'] when 'at' then "@#{user msg['data']['qq'], @info['group_id']} " when 'image' then msg['data']['url'] else QQ.cq_call msg end end end |
#run ⇒ Object
13 14 15 16 17 |
# File 'lib/matrix_qq/qq/forward_group/matrix.rb', line 13 def run msg = @info['message'] sender = user @info['user_id'], @info['group_id'] MatrixQQ::Matrix::Send.text @matrix, @room, "[#{sender}] #{msg}" end |
#user(user, group_id = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/matrix_qq/qq/forward_group/matrix.rb', line 30 def user(user, group_id = nil) if group_id.nil? return @dbus.get_stranger_info(user_id: user)['nickname'] end info = @dbus.get_group_member_info(user_id: user, group_id: group_id) info = info['data'] name = info['card'] name == '' ? info['nickname'] : name end |