new (Irc::IrcBot)

    # File rbot/ircbot.rb, line 59
      def initialize(botclass)
        @botclass = botclass
        @botclass.gsub!(/\/$/, "")
        Dir.mkdir("#{botclass}") if(!File.exist?("#{botclass}"))
        Dir.mkdir("#{botclass}/logs") if(!File.exist?("#{botclass}/logs"))
        @lang = Irc::Language.new("english")
        @timer = Timer::Timer.new
        @timer.add(60) { save }
        @channels = Hash.new
        @logs = Hash.new
        @config = Irc::BotConfig.new(self)
        @keywords = Irc::Keywords.new(self)
        @auth = Irc::IrcAuth.new(self)
        @plugins = Irc::Plugins.new(self, ["#{botclass}/plugins"])
        @socket = Irc::IrcSocket.new(@config["SERVER"], @config["PORT"], @config["HOST"])
        @nick = @config["NICK"]
        @server_password = @config["SERVER_PASSWORD"]

        @client = Irc::IrcClient.new
        @client["PRIVMSG"] = proc { |data|
          message = PrivMessage.new(self, data["SOURCE"], data["TARGET"], data["MESSAGE"])
          privmsg(message)
        }
        @client["NOTICE"] = proc { |data|
          message = NoticeMessage.new(self, data["SOURCE"], data["TARGET"], data["MESSAGE"])
          # pass it off to plugins that want to hear everything
          @plugins.delegate "listen", message
        }
        @client["MOTD"] = proc { |data|
          data['MOTD'].each_line { |line|
            log "MOTD: #{line}", "server"
          }
        }
        @client["NICKTAKEN"] = proc { |data|
          nickchg "#{@nick}_"
        }
        @client["BADNICK"] = proc {|data|
          puts "WARNING, bad nick (#{data['NICK']})"
        }
        @client["PING"] = proc {|data|
          @socket.puts "PONG #{data['PINGID']}"
        }
        @client["NICK"] = proc {|data|
          sourcenick = data["SOURCENICK"]
          nick = data["NICK"]
          if(sourcenick == @nick)
            @nick = nick
          end
          @channels.each {|k,v|
            if(v.users.has_key?(sourcenick))
              log "@ #{sourcenick} is now known as #{nick}", k
              v.users[nick] = v.users[sourcenick]
              v.users.delete(sourcenick)
            end
          }
        }
        @client["QUIT"] = proc {|data|
          source = data["SOURCE"]
          sourcenick = data["SOURCENICK"]
          sourceurl = data["SOURCEADDRESS"]
          message = data["MESSAGE"]
          if(data["SOURCENICK"] =~ /#{@nick}/)
          else
            @channels.each {|k,v|
              if(v.users.has_key?(sourcenick))
                log "@ Quit: #{sourcenick}: #{message}", k
                v.users.delete(sourcenick)
              end
            }
          end
        }
        @client["MODE"] = proc {|data|
          source = data["SOURCE"]
          sourcenick = data["SOURCENICK"]
          sourceurl = data["SOURCEADDRESS"]
          channel = data["CHANNEL"]
          targets = data["TARGETS"]
          modestring = data["MODESTRING"]
          log "@ Mode #{modestring} #{targets} by #{sourcenick}", channel
        }
        @client["WELCOME"] = proc {|data|
          log "joined server #{data['SOURCE']} as #{data['NICK']}", "server"
          debug "I think my nick is #{@nick}, server thinks #{data['NICK']}"
          @nick = data['NICK']
          if(@config["JOIN_CHANNELS"])
            @config["JOIN_CHANNELS"].split(", ").each {|c|
              puts "autojoining channel #{c}"
              if(c =~ /^(\S+)\s+(\S+)$/)
                join $1, $2
              else
                join c if(c)
              end
            }
          end
        }
        @client["JOIN"] = proc {|data|
          channel = data["CHANNEL"]

          @channels[channel] = IRCChannel.new(channel) unless(@channels.has_key?(channel))
          if(data["SOURCENICK"] =~ /#{@nick}/)
            log "@ Joined channel #{channel}", channel
            puts "joined channel #{channel}"
          else
            log "@ #{data['SOURCENICK']} joined channel #{data['CHANNEL']}", data["CHANNEL"]
            @channels[channel].users[data['SOURCENICK']] = Hash.new
            @channels[channel].users[data['SOURCENICK']]["mode"] = ""
          end
        }
        @client["PART"] = proc {|data|
          channel = data["CHANNEL"]
          sourcenick = data["SOURCENICK"]
          if(sourcenick =~ /#{@nick}/)
            log "@ Left channel #{channel}", channel
            @channels.delete(channel)
            puts "left channel #{channel}"
          else
            log "@ #{sourcenick} left channel #{channel}", channel
            @channels[channel].users.delete(sourcenick)
          end
        }
        @client["KICK"] = proc {|data|
          m = KickMessage.new(self, data["SOURCE"], data["TARGET"],data["CHANNEL"],data["MESSAGE"])
          kicked(m)
          @plugins.delegate("kick", m)
        }
        @client["INVITE"] = proc {|data|
          if(data["TARGET"] =~ /^#{@nick}$/)
            join data["CHANNEL"] if (@auth.allow?("join", data["SOURCE"], data["SOURCENICK"]))
          end
        }
        @client["CHANGETOPIC"] = proc {|data|
          channel = data["CHANNEL"]
          sourcenick = data["SOURCENICK"]
          topic = data["TOPIC"]
          if(sourcenick == @nick)
            log "@ I set topic \"#{topic}\"", channel
          else
            log "@ #{sourcenick} set topic \"#{topic}\"", channel
          end
        }
        @client["NAMES"] = proc {|data|
          channel = data["CHANNEL"]
          users = data["USERS"]
          unless(@channels[channel])
            puts "bug: got names for channel '#{channel}' I didn't think I was in\n"
            exit 2
          end
          @channels[channel].users.clear
          users.each {|u|
            @channels[channel].users[u[0]] = ["mode", u[1]]
          }
        }
        @client["UNKNOWN"] = proc {|data|
          debug "UNKNOWN: #{data['SERVERSTRING']}"
        }
      end