- add "wallchan" command
authorAndreas Scherbaum <andreas@scherbaum.biz>
Sat, 19 May 2012 21:01:52 +0000 (23:01 +0200)
committerAndreas Scherbaum <andreas@scherbaum.biz>
Sat, 19 May 2012 21:01:52 +0000 (23:01 +0200)
- add translations for "wallchan" command

docbot.conf
docbot.pl

index fe6487e57860c93b74321737287ec53de8d8277e..0315f46122cc49b73e31af95ca64adea19c657d2 100644 (file)
@@ -82,6 +82,8 @@ translations:
     more_results_at: 'Mehr Ergebnisse unter'
     more_result: 'weiteres Ergebnis'
     more_results: 'weitere Ergebnisse'
+    error_wallchan_command_parameter: 'Der "wallchan" Befehl erfordert einen Parameter'
+    wallchan_command_message: 'Nachricht vom Operator'
   fr:
     learn: 'apprendre'
     forget: 'oublier'
index ce0ae5a59879b8c2f451d92115f9b613bd0b39eb..26afe0906f7a9e4869014bad72c9aaaf91b69bae 100755 (executable)
--- a/docbot.pl
+++ b/docbot.pl
@@ -1219,6 +1219,8 @@ sub is_valid_admin_command {
         return 1;
     } elsif ($command eq 'status') {
         return 1;
+    } elsif ($command eq 'wallchan') {
+        return 1;
     }
 
     return 0;
@@ -1645,6 +1647,7 @@ sub handle_command {
         }
         case('wallchan') {
             $main::statistics{'command_counter_wallchan'}++;
+            return handle_command_wallchan($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
         }
     }
 
@@ -1727,6 +1730,65 @@ sub handle_command_status {
 }
 
 
+# handle_command_wallchan()
+#
+# command handler for the 'wallchan' command
+#
+# parameter:
+#  - the command (lower case)
+#  - the parameter string (may be empty)
+#  - the command mode (admin/operator/user)
+#  - POE kernel
+#  - POE heap
+#  - the full who of the message sender, including the nick name
+#  - the nick name of the message sender
+#  - the full origin of the message
+#  - the message itself
+#  - POE sender
+#  - session irc handle
+#  - the channel name
+# return:
+#  - text to send back to the sender
+sub handle_command_wallchan {
+    my $command = shift;
+    my $string = shift;
+    my $mode = shift;
+    my $kernel = shift;
+    my $heap = shift;
+    my $who = shift;
+    my $nick = shift;
+    my $where = shift;
+    my $msg = shift;
+    my $sender = shift;
+    my $irc = shift;
+    my $channel = shift;
+
+
+    if (length($string) < 1) {
+        my $answer = 'The "wallchan" command requires a parameter';
+        $answer = translate_text_for_channel($channel, 'error_wallchan_command_parameter', $answer);
+        return $answer;
+    }
+
+    print_msg("wallchan: '$string', by $nick", DEBUG);
+    send_to_commandchannel("wallchan: '$string', by $nick");
+
+
+    my @channels = ();
+    foreach my $tmp_session (keys(%main::sessions)) {
+        push(@channels, @{$main::sessions{$tmp_session}{'joined_channels'}});
+    }
+    foreach my $tmp_channel (@channels) {
+        my $answer = 'Operator message';
+        $answer = translate_text_for_channel($tmp_channel, 'wallchan_command_message', $answer);
+        send_to_channel($tmp_channel, $answer . ': ' . $string);
+    }
+
+
+    return '';
+}
+
+
 # handle_command_search()
 #
 # command handler for the 'search' command