summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-10 01:37:06 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-10 01:37:06 +0000
commit4bbc1b813729b01c51ae5922e994325f27c5c1ed (patch)
tree7713eebe5e9b227785a6b4229c7ba34444a9c908 /lib/rbot
parentc705ba5a89cd7b5c19677f4950c9784828ffc5c6 (diff)
Option to change the bot IRC name, thanks to jsn-
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb13
1 files changed, 12 insertions, 1 deletions
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']