Sha256: 262861f6b4df10059c19a8b0e8e028707214ddfca10dfb263eade33f18dacaf3

Contents?: true

Size: 694 Bytes

Versions: 3

Compression:

Stored size: 694 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.mention_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

3 entries across 3 versions & 1 rubygems

Version Path
lita-1.1.2 lib/lita/message.rb
lita-1.1.1 lib/lita/message.rb
lita-1.1.0 lib/lita/message.rb