- improve "say" command
authorAndreas Scherbaum <andreas@scherbaum.biz>
Wed, 13 Jun 2012 12:13:12 +0000 (14:13 +0200)
committerAndreas Scherbaum <andreas@scherbaum.biz>
Wed, 13 Jun 2012 12:13:12 +0000 (14:13 +0200)
docbot.conf
docbot.pl

index c0caf702d4f5fc240ba13a7e03d889042ae3c1b0..0a5c940b8a423910bb032c72669ed712d1b52568 100644 (file)
@@ -86,6 +86,7 @@ translations:
     error_wallchan_command_parameter: 'Der "wallchan" Befehl erfordert einen Parameter'
     wallchan_command_message: 'Nachricht vom Operator'
     error_say_command_parameter: 'Der "say" Befehl erfordert zwei Parameter'
+    error_say_not_joined: 'Der Bot ist nicht in diesem Channel'
     error_join_command_parameter: 'Der "join" Befehl erfordert zwei Parameter'
     error_join_already_joined: 'Der Bot ist bereits in diesem Channel'
     error_leave_command_parameter: 'Der "leave" Befehl erfordert einen Parameter'
index 5ec31586d21acb3e4b8535c59015577658af219b..91f268dea1371b859d3f7e90f75d1538d6049e4d 100755 (executable)
--- a/docbot.pl
+++ b/docbot.pl
@@ -1812,7 +1812,6 @@ sub handle_command {
             return handle_command_wallchan($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
         }
         case('say') {
-            $main::statistics{'command_counter_say'}++;
             return handle_command_say($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
         }
         case('join') {
@@ -1999,7 +1998,7 @@ sub handle_command_say {
 
 
     if (length($string) < 1) {
-        my $answer = 'The "say" command requires two parameter';
+        my $answer = 'The "say" command requires two parameters';
         $answer = translate_text_for_channel($channel, 'error_say_command_parameter', $answer);
         return $answer;
     }
@@ -2015,22 +2014,32 @@ sub handle_command_say {
         $msg_channel = $1;
         $message = $2;
     } else {
-        my $answer = 'The "say" command requires two parameter';
+        my $answer = 'The "say" command requires two parameters';
         $answer = translate_text_for_channel($channel, 'error_say_command_parameter', $answer);
         return $answer;
     }
 
     if (!is_a_channel($msg_channel)) {
-        my $answer = 'The "say" command requires two parameter';
+        my $answer = 'The "say" command requires two parameters';
         $answer = translate_text_for_channel($channel, 'error_say_command_parameter', $answer);
         return $answer;
     }
 
+    my $msg_session = session_for_channel($msg_channel);
+
+    if (!$msg_session) {
+        my $answer = 'The bot is not in this channel';
+        $answer = translate_text_for_channel($channel, 'error_say_not_joined', $answer);
+        return $answer;
+    }
+
+
     print_msg("say: '$message' in '$msg_channel', by $nick", DEBUG);
     send_to_commandchannel("say: '$message' in '$msg_channel', by $nick");
 
 
     send_to_channel($msg_channel, $message);
+    $main::statistics{'command_counter_say'}++;
 
 
     return '';