Class: MatrixQQ::QQ::ForwardFriend::Matrix

Inherits:
Object
  • Object
show all
Defined in:
lib/matrix_qq/qq/forward_friend/matrix.rb

Instance Method Summary collapse

Constructor Details

#initialize(dbus, matrix, info, room) ⇒ Matrix

Returns a new instance of Matrix.



5
6
7
8
9
10
# File 'lib/matrix_qq/qq/forward_friend/matrix.rb', line 5

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

Instance Method Details

#message(messages) ⇒ Object



18
19
20
21
22
# File 'lib/matrix_qq/qq/forward_friend/matrix.rb', line 18

def message(messages)
  messages.inject('') do |obj, msg|
    obj + QQ.cq_call(msg)
  end
end

#runObject



12
13
14
15
16
# File 'lib/matrix_qq/qq/forward_friend/matrix.rb', line 12

def run
  msg = message @info['message']
  sender = "[#{user @info['user_id']}] " if @info['print_sender']
  MatrixQQ::Matrix::Send.text @matrix, @room, "#{sender}#{msg}"
end

#user(user) ⇒ Object



24
25
26
# File 'lib/matrix_qq/qq/forward_friend/matrix.rb', line 24

def user(user)
  @dbus.get_stranger_info(user_id: user)['data']['nickname']
end