Method: Cinch::Target#send

Defined in:
lib/cinch/target.rb

#send(text, notice = false) ⇒ void

Note:

The aliases msg and privmsg are deprecated and will be removed in a future version.

This method returns an undefined value.

Sends a PRIVMSG to the target.

Parameters:

  • text (#to_s)

    the message to send

  • notice (Boolean) (defaults to: false)

    Use NOTICE instead of PRIVMSG?

See Also:

Since:

  • 2.0.0



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cinch/target.rb', line 34

def send(text, notice = false)
  # TODO deprecate `notice` argument, put splitting into own
  # method
  text = text.to_s
  split_start = @bot.config.message_split_start || ""
  split_end = @bot.config.message_split_end || ""
  command = notice ? "NOTICE" : "PRIVMSG"
  prefix = ":#{@bot.mask} #{command} #{@name} :"

  text.lines.map(&:chomp).each do |line|
    splitted = split_message(line, prefix, split_start, split_end)

    splitted[0, (@bot.config.max_messages || splitted.size)].each do |string|
      @bot.irc.send("#{command} #{@name} :#{string}")
    end
  end
end