summaryrefslogtreecommitdiff
path: root/lib/rbot/channel.rb
blob: 34804c19c6b61e5cf8557b3222745d39a21efb4a (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module Irc

  # class to store IRC channel data (users, topic, per-channel configurations)
  class IRCChannel
    # name of channel
    attr_reader :name

    # current channel topic
    attr_reader :topic

    # hash containing users currently in the channel
    attr_accessor :users

    # if true, bot won't talk in this channel
    attr_accessor :quiet

    # name:: channel name
    # create a new IRCChannel
    def initialize(name)
      @name = name
      @users = Hash.new
      @quiet = false
      @topic = Topic.new
    end

    # eg @bot.channels[chan].topic = topic
    def topic=(name)
      @topic.name = name
    end

    # class to store IRC channel topic information
    class Topic
      # topic name
      attr_accessor :name

      # timestamp
      attr_accessor :timestamp

      # topic set by
      attr_accessor :by

      def initialize
        @name = ""
      end

      # when called like "puts @bots.channels[chan].topic"
      def to_s
        @name
      end
    end

  end

end