Class: KAG::Bot::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/kag/bot/bot.rb

Instance Method Summary collapse

Constructor Details

#initializeBot

Returns a new instance of Bot.



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
55
56
57
# File 'lib/kag/bot/bot.rb', line 18

def initialize
  config = self.config
  bot = Cinch::Bot.new do
    configure do |c|
      c.server = config[:server]
      c.channels = config[:channels]
      c.port = config[:port].to_i > 0 ? config[:port] : 6667
      #c.ssl = config[:ssl]
      c.nick = config[:nick].to_s != "" ? config[:nick] : "KAGatherer"
      c.user = config[:user].to_s != "" ? config[:user] : c.nick
      c.realname = config[:realname].to_s != "" ? config[:realname] : "KAG Gatherer"
      c.messages_per_second = 2
      c.modes = %w(x)
      c.plugins.plugins = [
        Cinch::Commands::Help,
        KAG::Bot::Plugin,
        KAG::Gather::Plugin,
        KAG::Bans::Plugin,
        KAG::IRC::Plugin,
        KAG::User::Plugin,
        KAG::Help::Plugin,
        KAG::Stats::Plugin
      ]
      if config[:auth] and config[:auth][:password]
        c.plugins.plugins << Cinch::Plugins::Identify
        c.plugins.options[Cinch::Plugins::Identify] = {
          :username => config[:auth][:username],
          :password => config[:auth][:password],
          :type     => :secure_quakenet,
        }
      end
      if config[:sasl]
        c.sasl.username = config[:sasl][:username]
        c.sasl.password = config[:sasl][:password]
      end
    end
  end

  bot.start
end

Instance Method Details

#configObject



59
60
61
# File 'lib/kag/bot/bot.rb', line 59

def config
  KAG::Config.instance
end