aboutsummaryrefslogtreecommitdiff
path: root/core/messageinfo.rb
blob: c9a12c44dd865ace6b8c98b19d8d2ad58d97f4f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Dinobot
  module Core
    class MessageInfo
      attr_accessor :user, :channel, :message, :response

      def initialize(user, channel, message)
        @user = user
        @channel = channel
        @message = message
        @response = []
      end

      def respond(arr)
        case arr.first
        when :say
          raise "wrong number of arguments -- #{arr}" unless arr.length == 3
        when :join, :part, :quit
          raise "wrong number of arguments -- #{arr}" unless arr.length == 2
        else
          raise "unknown method name -- #{arr}"
        end

        @response << arr
      end

      def response?
        !@response.empty?
      end
    end
  end
end