From: Giuseppe Bilotta Date: Sat, 10 Mar 2007 01:37:06 +0000 (+0000) Subject: Option to change the bot IRC name, thanks to jsn- X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=4bbc1b813729b01c51ae5922e994325f27c5c1ed;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git Option to change the bot IRC name, thanks to jsn- --- diff --git a/ChangeLog b/ChangeLog index 403e8c41..34b7e41a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-03-10 Giuseppe Bilotta + + * IRC settings: ability to change the IRC name for the bot. Thanks to + jsn- (Dmitry Kim ). + 2007-02-20 Giuseppe Bilotta * Timers: failing timer actions don't prevent the global timer ticker diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 491fa517..7c0af845 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -89,6 +89,7 @@ module Irc # Main bot class, which manages the various components, receives messages, # handles them or passes them to plugins, and contains core functionality. class Bot + COPYRIGHT_NOTICE = "(c) Tom Gilbert and the rbot development team" # the bot's Auth data attr_reader :auth @@ -183,6 +184,12 @@ class Bot BotConfig.register BotConfigStringValue.new('irc.nick', :default => "rbot", :desc => "IRC nickname the bot should attempt to use", :wizard => true, :on_change => Proc.new{|bot, v| bot.sendq "NICK #{v}" }) + BotConfig.register BotConfigStringValue.new('irc.name', + :default => "Ruby bot", :requires_restart => true, + :desc => "IRC realname the bot should use") + BotConfig.register BotConfigBooleanValue.new('irc.name_copyright', + :default => true, :requires_restart => true, + :desc => "Append copyright notice to bot realname? (please don't disable unless it's really necessary)") BotConfig.register BotConfigStringValue.new('irc.user', :default => "rbot", :requires_restart => true, :desc => "local user the bot should appear to be", :wizard => true) @@ -697,8 +704,12 @@ class Bot raise e.class, "failed to connect to IRC server at #{@config['server.name']} #{@config['server.port']}: " + e end quit if $interrupted > 0 + + realname = @config['irc.name'].clone || 'Ruby bot' + realname << ' ' + COPYRIGHT_NOTICE if @config['irc.name_copyright'] + @socket.emergency_puts "PASS " + @config['server.password'] if @config['server.password'] - @socket.emergency_puts "NICK #{@config['irc.nick']}\nUSER #{@config['irc.user']} 4 #{@config['server.name']} :Ruby bot. (c) Tom Gilbert and the rbot development team" + @socket.emergency_puts "NICK #{@config['irc.nick']}\nUSER #{@config['irc.user']} 4 #{@config['server.name']} :#{realname}" quit if $interrupted > 0 myself.nick = @config['irc.nick'] myself.user = @config['irc.user']