summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/basics.rb26
-rw-r--r--lib/rbot/ircbot.rb9
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