# File rbot.rb, line 429 def privmsg(m) # log it first if(m.message =~ /^\001ACTION\s+(.+)\001/) if(m.private?) log "* [#{m.sourcenick}(#{m.sourceaddress})] #$1", m.sourcenick else log "* #{m.sourcenick} #$1", m.target end else if(m.public?) log "<#{m.sourcenick}> #{m.message}", m.target else log "[#{m.sourcenick}(#{m.sourceaddress})] #{m.message}", m.sourcenick end end # pass it off to plugins that want to hear everything @plugins.listen(m) if(m.private? && m.message =~ /^\001PING\s+(.+)\001/) notice m.sourcenick, "\001PING #$1\001" log "@ #{m.sourcenick} pinged me" return end if(m.address?) case m.message when (/^join\s+(\S+)\s+(\S+)$/) join $1, $2 if(@auth.allow?("join", m.source, m.replytok)) when (/^join\s+(\S+)$/) join $1 if(@auth.allow?("join", m.source, m.replyto)) when (/^part$/) part m.target if(m.public? && @auth.allow?("join", m.source, m.replyto)) when (/^part\s+(\S+)$/) part $1 if(@auth.allow?("join", m.source, m.replyto)) when (/^quit(?:\s+(.*))?$/) quit $1 if(@auth.allow?("quit", m.source, m.replyto)) when (/^hide$/) join 0 if(@auth.allow?("join", m.source, m.replyto)) when (/^save$/) if(@auth.allow?("config", m.source, m.replyto)) okay m.replyto save end when (/^nick\s+(\S+)$/) nickchg($1) if(@auth.allow?("nick", m.source, m.replyto)) when (/^say\s+(\S+)\s+(.*)$/) say $1, $2 if(@auth.allow?("say", m.source, m.replyto)) when (/^action\s+(\S+)\s+(.*)$/) action $1, $2 if(@auth.allow?("say", m.source, m.replyto)) when (/^topic\s+(\S+)\s+(.*)$/) topic $1, $2 if(@auth.allow?("topic", m.source, m.replyto)) when (/^ping$/) say m.replyto, "pong" when (/^rescan$/) if(@auth.allow?("config", m.source, m.replyto)) okay m.replyto rescan end when (/^quiet$/) if(auth.allow?("talk", m.source, m.replyto)) say m.replyto, @lang.get("okay") @channels.each_value {|c| c.quiet = true } end when (/^quiet in (\S+)$/) where = $1 if(auth.allow?("talk", m.source, m.replyto)) say m.replyto, @lang.get("okay") where.gsub!(/^here$/, m.target) if m.public? @channels[where].quiet = true if(@channels.has_key?(where)) end when (/^talk$/) if(auth.allow?("talk", m.source, m.replyto)) @channels.each_value {|c| c.quiet = false } okay m.replyto end when (/^talk in (\S+)$/) where = $1 if(auth.allow?("talk", m.source, m.replyto)) where.gsub!(/^here$/, m.target) if m.public? @channels[where].quiet = false if(@channels.has_key?(where)) okay m.replyto end when (/^(version)|(introduce yourself)$/) say m.replyto, "I'm a v. #{$version} rubybot, (c) Tom Gilbert - http://linuxbrit.co.uk/rbot/" when (/^help(?:\s+(.*))?$/) help(m, $1) when (/^(botsnack|ciggie)$/) say m.replyto, @lang.get("thanks_X") % m.sourcenick if(m.public?) say m.replyto, @lang.get("thanks") if(m.private?) when (/^(hello|howdy|hola|salut|bonjour|niihau|hey|hi(\W|$)|yo(\W|$)).*/) say m.replyto, @lang.get("hello_X") % m.sourcenick if(m.public?) say m.replyto, @lang.get("hello") if(m.private?) else delegate_privmsg(m) end else # stuff to handle when not addressed case m.message when (/^\s*(hello|howdy|hola|salut|bonjour|niihau|hey|hi(\W|$)|yo(\W|$)).*#{@nick}/) say m.replyto, @lang.get("hello_X") % m.sourcenick when (/^#{@nick}!?$/) say m.replyto, @lang.get("hello_X") % m.sourcenick else @keywords.privmsg(m) end end end