Method: Lita::Robot#send_messages_with_mention

Defined in:
lib/lita/robot.rb

#send_messages_with_mention(target, *strings) ⇒ void Also known as: send_message_with_mention

This method returns an undefined value.

Sends one or more messages to a user or room. If sending to a room, prefixes each message with the user’s mention name.

Parameters:

  • target (Lita::Source)

    The user or room to send to. If the Source has a room, it will choose the room. Otherwise, it will send to the user.

  • strings (String, Array<String>)

    One or more strings to send.

Since:

  • 3.1.0



141
142
143
144
145
146
147
148
149
150
# File 'lib/lita/robot.rb', line 141

def send_messages_with_mention(target, *strings)
  return send_messages(target, *strings) if target.private_message?

  mention_name = target.user.mention_name
  prefixed_strings = strings.map do |s|
    "#{adapter.mention_format(mention_name).strip} #{s}"
  end

  send_messages(target, *prefixed_strings)
end