Sha256: 51e07a3235ab21deca72e9e59124125fce07a548282d219551280aa76f831133

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

Stored size: 686 Bytes

Contents

module Lita
  class Message
    extend Forwardable

    attr_reader :body, :source
    alias_method :message, :body

    def_delegators :@body, :scan
    def_delegators :@source, :user

    def initialize(robot, body, source)
      @robot = robot
      @body = body
      @source = source

      @command = !!@body.sub!(/^\s*@?#{@robot.name}[:,]?\s*/, "")
    end

    def args
      begin
        command, *args = message.shellsplit
      rescue ArgumentError
        command, *args =
          message.split(/\s+/).map(&:shellescape).join(" ").shellsplit
      end

      args
    end

    def command!
      @command = true
    end

    def command?
      @command
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-1.0.0 lib/lita/message.rb