# File lib/rbot/ircbot.rb, line 597
  def sendmsg(type, where, message, chan=nil, ring=0)
    # limit it according to the byterate, splitting the message
    # taking into consideration the actual message length
    # and all the extra stuff
    # TODO allow something to do for commands that produce too many messages
    # TODO example: math 10**10000
    left = @socket.bytes_per - type.length - where.length - 4
    begin
      if(left >= message.length)
        sendq "#{type} #{where} :#{message}", chan, ring
        log_sent(type, where, message)
        return
      end
      line = message.slice!(0, left)
      lastspace = line.rindex(/\s+/)
      if(lastspace)
        message = line.slice!(lastspace, line.length) + message
        message.gsub!(/^\s+/, "")
      end
      sendq "#{type} #{where} :#{line}", chan, ring
      log_sent(type, where, line)
    end while(message.length > 0)
  end