]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Option to change the bot IRC name, thanks to jsn-
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 10 Mar 2007 01:37:06 +0000 (01:37 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 10 Mar 2007 01:37:06 +0000 (01:37 +0000)
ChangeLog
lib/rbot/ircbot.rb

index 403e8c4129156cb5b8f8e83ff40189f179e93b4a..34b7e41a5dc8367a460486788821b709f9bfcfbe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-10  Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
+
+       * IRC settings: ability to change the IRC name for the bot. Thanks to
+       jsn- (Dmitry Kim <dmitry.kim@gmail.com>).
+
 2007-02-20  Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
 
        * Timers: failing timer actions don't prevent the global timer ticker
index 491fa5178eefb9b696c34591f15cb50d24966160..7c0af845750676e148358213316dd8a881b1882f 100644 (file)
@@ -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']