Sha256: 5c224c574777f0782efb3c9e4ba71d9be90fdea65f4bca6410287b972ef719cd

Contents?: true

Size: 613 Bytes

Versions: 3

Compression:

Stored size: 613 Bytes

Contents

# frozen_string_literal: true

module Del
  # An XMPP Message
  class Message
    PREFIX = '/code'
    attr_reader :text, :robot, :source

    def initialize(text, robot:, source:)
      @text = text
      @robot = robot
      @source = source
    end

    def reply(message)
      source.reply(robot, message)
    end

    def execute_shell(command)
      reply("Okay, I'm on it!")
      ShellCommand.new(command).run do |line|
        if block_given?
          yield line
        else
          reply("#{PREFIX} #{line}")
        end
      end
    end

    def to_s
      "#{source}: #{text}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
del-0.1.19 lib/del/message.rb
del-0.1.18 lib/del/message.rb
del-0.1.17 lib/del/message.rb