- log "[#{m.sourcenick}(#{m.sourceaddress})] #{m.message}", m.sourcenick
- end
- end
-
- # pass it off to plugins that want to hear everything
- @plugins.delegate "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+)$/i)
- join $1, $2 if(@auth.allow?("join", m.source, m.replyto))
- when (/^join\s+(\S+)$/i)
- join $1 if(@auth.allow?("join", m.source, m.replyto))
- when (/^part$/i)
- part m.target if(m.public? && @auth.allow?("join", m.source, m.replyto))
- when (/^part\s+(\S+)$/i)
- part $1 if(@auth.allow?("join", m.source, m.replyto))
- when (/^quit(?:\s+(.*))?$/i)
- quit $1 if(@auth.allow?("quit", m.source, m.replyto))
- when (/^hide$/i)
- join 0 if(@auth.allow?("join", m.source, m.replyto))
- when (/^save$/i)
- if(@auth.allow?("config", m.source, m.replyto))
- save
- m.okay
- end
- when (/^nick\s+(\S+)$/i)
- nickchg($1) if(@auth.allow?("nick", m.source, m.replyto))
- when (/^say\s+(\S+)\s+(.*)$/i)
- say $1, $2 if(@auth.allow?("say", m.source, m.replyto))
- when (/^action\s+(\S+)\s+(.*)$/i)
- action $1, $2 if(@auth.allow?("say", m.source, m.replyto))
- when (/^topic\s+(\S+)\s+(.*)$/i)
- topic $1, $2 if(@auth.allow?("topic", m.source, m.replyto))
- when (/^mode\s+(\S+)\s+(\S+)\s+(.*)$/i)
- mode $1, $2, $3 if(@auth.allow?("mode", m.source, m.replyto))
- when (/^ping$/i)
- say m.replyto, "pong"
- when (/^rescan$/i)
- if(@auth.allow?("config", m.source, m.replyto))
- m.okay
- rescan
- end
- when (/^quiet$/i)
- if(auth.allow?("talk", m.source, m.replyto))
- m.okay
- @channels.each_value {|c| c.quiet = true }
- end
- when (/^quiet in (\S+)$/i)
- where = $1
- if(auth.allow?("talk", m.source, m.replyto))
- m.okay
- where.gsub!(/^here$/, m.target) if m.public?
- @channels[where].quiet = true if(@channels.has_key?(where))
- end
- when (/^talk$/i)
- if(auth.allow?("talk", m.source, m.replyto))
- @channels.each_value {|c| c.quiet = false }
- m.okay
- end
- when (/^talk in (\S+)$/i)
- 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))
- m.okay
- end
- # TODO break this out into a config module
- when (/^options get sendq_delay$/i)
- if auth.allow?("config", m.source, m.replyto)
- m.reply "options->sendq_delay = #{@socket.sendq_delay}"
- end
- when (/^options get sendq_burst$/i)
- if auth.allow?("config", m.source, m.replyto)
- m.reply "options->sendq_burst = #{@socket.sendq_burst}"
- end
- when (/^options set sendq_burst (.*)$/i)
- num = $1.to_i
- if auth.allow?("config", m.source, m.replyto)
- @socket.sendq_burst = num
- @config['irc.sendq_burst'] = num
- m.okay
- end
- when (/^options set sendq_delay (.*)$/i)
- freq = $1.to_f
- if auth.allow?("config", m.source, m.replyto)
- @socket.sendq_delay = freq
- @config['irc.sendq_delay'] = freq
- m.okay
- end
- when (/^status\??$/i)
- m.reply status if auth.allow?("status", m.source, m.replyto)
- when (/^registry stats$/i)
- if auth.allow?("config", m.source, m.replyto)
- m.reply @registry.stat.inspect
- end
- when (/^(help\s+)?config(\s+|$)/)
- @config.privmsg(m)
- when (/^(version)|(introduce yourself)$/i)
- say m.replyto, "I'm a v. #{$version} rubybot, (c) Tom Gilbert - http://linuxbrit.co.uk/rbot/"
- when (/^help(?:\s+(.*))?$/i)
- say m.replyto, help($1)
- #TODO move these to a "chatback" plugin
- when (/^(botsnack|ciggie)$/i)
- 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|sup|niihau|hey|hi(\W|$)|yo(\W|$)).*/i)
- 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|sup|niihau|hey|hi(\W|$)|yo(\W|$))[\s,-.]+#{@nick}$/i)
- say m.replyto, @lang.get("hello_X") % m.sourcenick
- when (/^#{@nick}!*$/)
- say m.replyto, @lang.get("hello_X") % m.sourcenick
- else
- @keywords.privmsg(m)