- implement "autojoin" configuration setting (default: yes)
authorAndreas Scherbaum <andreas@scherbaum.biz>
Sat, 11 Aug 2012 23:07:50 +0000 (01:07 +0200)
committerAndreas Scherbaum <andreas@scherbaum.biz>
Sat, 11 Aug 2012 23:07:50 +0000 (01:07 +0200)
docbot.conf
docbot.pl
todo.txt

index c716513f6fe8c3ab1ff4a4ec5c14fd8b2904ca5d..9e9babc2386df3ff3d1e7db618220528ad6ba42b 100644 (file)
@@ -4,6 +4,7 @@ channels:
     password: ''
     session: 1
     language: 'de'
+    autojoin: '1'
   '#pg_docbot_test1':
     password: ''
     session: 2
index 24b96eecd92d2e156ab14106333d8bf191bf428a..33787f6a681081ff7caa0c36a13030037d801d09 100755 (executable)
--- a/docbot.pl
+++ b/docbot.pl
@@ -3515,7 +3515,21 @@ sub on_connect {
     my @join_channels = ();
     foreach my $channel (@channels) {
         my $channel_session = config_get_key3('channels', $channel, 'session');
-        if ($channel_session == $session) {
+        my $channel_autojoin = config_get_key3('channels', $channel, 'autojoin');
+        if (!defined($channel_autojoin)) {
+            $channel_autojoin = '';
+        }
+        # autojoin is the default
+        my $channel_autojoin_result = 1;
+        given ($channel_autojoin) {
+            when(/^0$/) {$channel_autojoin_result = 0;}
+            when(/^n$/) {$channel_autojoin_result = 0;}
+            when(/^no$/) {$channel_autojoin_result = 0;}
+            when(/^1$/) {$channel_autojoin_result = 1;}
+            when(/^y$/) {$channel_autojoin_result = 1;}
+            when(/^yes$/) {$channel_autojoin_result = 1;}
+        }
+        if ($channel_session == $session and $channel_autojoin_result == 1) {
             push(@join_channels, $channel);
             print_msg("assign irc channel '$channel' to session '$session'", DEBUG);
         }
index b8b1e0ad4a33539ec4264fec5ad5d1c5c6e862a9..536baa4a8c2e2f9941806118acd37cae19a7ac8c 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -9,7 +9,6 @@
 - nickserv handling (passwords)
 - verify channel list from time to time, autojoin missing channels
 - allow a password for the ?join command
-- predefine channels in the configuration which are not autojoined
 
 
 
@@ -29,3 +28,4 @@
 - verify existence of required tables at startup OK
 - move translations to a separate file OK
 - channel passwords OK
+- predefine channels in the configuration which are not autojoined OK