X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fircbot.rb;h=42e3c9b6e801d7d9d805fc313aa610b9a513dc27;hb=2ecf2f58c843895ce4ad143d0a05283c4b7e37e8;hp=3b42a3aa19048abdce9f707701e42e823b821097;hpb=922c6a35bb34598da397d2a0078adc397e84a853;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 3b42a3aa..42e3c9b6 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -124,7 +124,7 @@ module Irc # handles them or passes them to plugins, and contains core functionality. class Bot COPYRIGHT_NOTICE = "(c) Tom Gilbert and the rbot development team" - SOURCE_URL = "http://linuxbrit.co.uk/rbot" + SOURCE_URL = "http://ruby-rbot.org" # the bot's Auth data attr_reader :auth @@ -178,6 +178,38 @@ class Bot myself.nick end + # bot inspection + # TODO multiserver + def inspect + ret = self.to_s[0..-2] + ret << ' version=' << $version.inspect + ret << ' botclass=' << botclass.inspect + ret << ' lang="' << lang.language + if defined?(GetText) + ret << '/' << locale + end + ret << '"' + ret << ' nick=' << nick.inspect + ret << ' server=' + if server + ret << (server.to_s + (socket ? + ' [' << socket.server_uri.to_s << ']' : '')).inspect + unless server.channels.empty? + ret << " channels=" + ret << server.channels.map { |c| + "%s%s" % [c.modes_of(nick).map { |m| + server.prefix_for_mode(m) + }, c.name] + }.inspect + end + else + ret << '(none)' + end + ret << ' plugins=' << plugins.inspect + ret << ">" + end + + # create a new Bot with botclass +botclass+ def initialize(botclass, params = {}) # Config for the core bot @@ -622,7 +654,7 @@ class Bot @plugins.delegate("listen", m) @plugins.delegate("join", m) - sendq "WHO #{data[:channel]}", data[:channel], 2 + sendq("WHO #{data[:channel]}", data[:channel], 2) if m.address? } @client[:part] = proc {|data| m = PartMessage.new(self, server, data[:source], data[:channel], data[:message]) @@ -1203,15 +1235,15 @@ class Bot def irclogprivmsg(m) if(m.action?) if(m.private?) - irclog "* [#{m.source}(#{m.sourceaddress})] #{m.message}", m.source + irclog "* [#{m.source}(#{m.sourceaddress})] #{m.logmessage}", m.source else - irclog "* #{m.source} #{m.message}", m.target + irclog "* #{m.source} #{m.logmessage}", m.target end else if(m.public?) - irclog "<#{m.source}> #{m.message}", m.target + irclog "<#{m.source}> #{m.logmessage}", m.target else - irclog "[#{m.source}(#{m.sourceaddress})] #{m.message}", m.source + irclog "[#{m.source}(#{m.sourceaddress})] #{m.logmessage}", m.source end end end @@ -1248,18 +1280,18 @@ class Bot def irclogpart(m) if(m.address?) debug "left channel #{m.channel}" - irclog "@ Left channel #{m.channel} (#{m.message})", m.channel + irclog "@ Left channel #{m.channel} (#{m.logmessage})", m.channel else - irclog "@ #{m.source} left channel #{m.channel} (#{m.message})", m.channel + irclog "@ #{m.source} left channel #{m.channel} (#{m.logmessage})", m.channel end end def irclogkick(m) if(m.address?) debug "kicked from channel #{m.channel}" - irclog "@ You have been kicked from #{m.channel} by #{m.source} (#{m.message})", m.channel + irclog "@ You have been kicked from #{m.channel} by #{m.source} (#{m.logmessage})", m.channel else - irclog "@ #{m.target} has been kicked from #{m.channel} by #{m.source} (#{m.message})", m.channel + irclog "@ #{m.target} has been kicked from #{m.channel} by #{m.source} (#{m.logmessage})", m.channel end end