]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/basics.rb
remove whitespace
[user/henk/code/ruby/rbot.git] / lib / rbot / core / basics.rb
index fd7a085f755191304c4a15cbccef83f632523f9b..832cbb25e73bf79ff1a080ab29a65ad5857ced4f 100644 (file)
@@ -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
@@ -164,7 +190,7 @@ basics.map "mode :where :what *who",
   :action => 'bot_mode',
   :auth_path => 'talk::do'
 
-basics.map "join :chan :pass", 
+basics.map "join :chan :pass",
   :action => 'bot_join',
   :defaults => {:pass => nil},
   :auth_path => 'move'