From 028534d8d925950863abbb9238e10fe924be5d14 Mon Sep 17 00:00:00 2001 From: Andreas Scherbaum Date: Wed, 13 Jun 2012 14:13:12 +0200 Subject: [PATCH] - improve "say" command --- docbot.conf | 1 + docbot.pl | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docbot.conf b/docbot.conf index c0caf70..0a5c940 100644 --- a/docbot.conf +++ b/docbot.conf @@ -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' diff --git a/docbot.pl b/docbot.pl index 5ec3158..91f268d 100755 --- 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 ''; -- 2.39.5