# 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
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
@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])
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
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