From 2bd4a7ed4ba5ab7c3c522c4d8061c1ce35bdc336 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 6 Aug 2008 21:36:41 +0200 Subject: [PATCH] basics: option to join channel after identification is confirmed Sometimes it is necessary to wait for identification to be confirmed before certain channels may be joined. In this case the option irc.join_after_identify can be set to true, and the bot will wait for nickserv to confirm the identification before joining any channels. This solution is actually a rather ugly hack, but I can't think of a better way to approach the problem without rewriting the whole framework. --- lib/rbot/core/basics.rb | 26 ++++++++++++++++++++++++++ lib/rbot/ircbot.rb | 9 --------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/rbot/core/basics.rb b/lib/rbot/core/basics.rb index fd7a085f..3fc794bc 100644 --- a/lib/rbot/core/basics.rb +++ b/lib/rbot/core/basics.rb @@ -7,6 +7,32 @@ class BasicsModule < CoreBotModule + Config.register Config::BooleanValue.new('irc.join_after_identify', + :default => false, :wizard => true, :requires_restart => true, + :desc => "Should the bot wait until its identification is confirmed before joining any channels?") + + def join_channels + @bot.config['irc.join_channels'].each { |c| + debug "autojoining channel #{c}" + if(c =~ /^(\S+)\s+(\S+)$/i) + @bot.join $1, $2 + else + @bot.join c if(c) + end + } + end + + def identified + join_channels + end + + # on connect, we join the default channels unless we have to wait for + # identification. Observe that this means the bot may not connect any channels + # until the 'identified' method gets delegated + def connect + join_channels unless @bot.config['irc.join_after_identify'] + end + def ctcp_listen(m) who = m.private? ? "me" : m.target case m.ctcp.intern diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 01dbb12b..0d934e33 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -609,15 +609,6 @@ class Bot @plugins.delegate("welcome", m) @plugins.delegate("connect") - - @config['irc.join_channels'].each { |c| - debug "autojoining channel #{c}" - if(c =~ /^(\S+)\s+(\S+)$/i) - join $1, $2 - else - join c if(c) - end - } } # TODO the next two @client should go into rfc2812.rb, probably -- 2.39.2