]> 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 2db2bcd84e71bd482a81685aeab54f4b6ae66e80..832cbb25e73bf79ff1a080ab29a65ad5857ced4f 100644 (file)
@@ -4,20 +4,42 @@
 # :title: rbot basic management from IRC
 #
 # Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
-# Copyright:: (C) 2006,2007 Giuseppe Bilotta
-# License:: GPL v2
 
 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
     when :PING
       m.ctcp_reply m.message
-      @bot.irclog "@ #{m.source} pinged #{who}"
     when :TIME
       m.ctcp_reply Time.now.to_s
-      @bot.irclog "@ #{m.source} asked #{who} what time it is"
     end
   end
 
@@ -117,8 +139,6 @@ class BasicsModule < CoreBotModule
       _("part <channel> => part channel <channel>")
     when "hide"
       _("hide => part all channels")
-    when "nick"
-      _("nick <nick> => attempt to change nick to <nick>")
     when "say"
       _("say <channel>|<nick> <message> => say <message> to <channel> or in private message to <nick>")
     when "action"
@@ -136,7 +156,7 @@ class BasicsModule < CoreBotModule
     #     when "hello"
     #       return "hello|hi|hey|yo [#{@bot.myself}] => greet the bot"
     else
-      _("%{name}: quit, restart, join, part, hide, save, nick, say, action, topic, quiet, talk, ping, mode") % {:name=>name}
+      _("%{name}: quit, restart, join, part, hide, save, say, action, topic, quiet, talk, ping, mode") % {:name=>name}
       #, botsnack, hello
     end
   end
@@ -170,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'