$main::statistics{'command_counter_config'} = 0;
$main::statistics{'command_counter_status'} = 0;
$main::statistics{'command_counter_wallchan'} = 0;
+ $main::statistics{'command_counter_say'} = 0;
$main::statistics{'command_access_denied'} = 0;
$main::statistics{'database_connects'} = 0;
return 1;
} elsif ($command eq 'wallchan') {
return 1;
+ } elsif ($command eq 'say') {
+ return 1;
}
return 0;
$main::statistics{'command_counter_wallchan'}++;
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);
+ }
}
push(@commands, 'forget: ' . $main::statistics{'command_counter_forget'});
push(@commands, 'config: ' . $main::statistics{'command_counter_config'});
push(@commands, 'wallchan: ' . $main::statistics{'command_counter_wallchan'});
+ push(@commands, 'say: ' . $main::statistics{'command_counter_say'});
push(@commands, 'status: ' . $main::statistics{'command_counter_status'});
$irc->yield( privmsg => $channel, 'Number of executed IRC commands: ' . join(", ", @commands) );
$irc->yield( privmsg => $channel, 'Number of denied IRC requests: ' . $main::statistics{'command_access_denied'} );
}
+# handle_command_say()
+#
+# command handler for the 'say' 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_say {
+ 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 "say" command requires two parameter';
+ $answer = translate_text_for_channel($channel, 'error_say_command_parameter', $answer);
+ return $answer;
+ }
+
+
+ # remove spaces at beginning and end
+ $string =~ s/^[\s\t]+//gs;
+ $string =~ s/[\s\t]+$//gs;
+
+
+ my ($msg_channel, $message);
+ if ($string =~ /^([^\s]+)\s+(.+)$/) {
+ $msg_channel = $1;
+ $message = $2;
+ } else {
+ my $answer = 'The "say" command requires two parameter';
+ $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';
+ $answer = translate_text_for_channel($channel, 'error_say_command_parameter', $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);
+
+
+ return '';
+}
+
+
# handle_command_search()
#
# command handler for the 'search' command
# translate message
$answer = translate_text_for_channel($replyto, 'help_general_line_3', $answer);
$answer .= ': ';
- $answer .= 'search, help, info, learn, forget, config, status, wallchan';
+ $answer .= 'search, help, info, learn, forget, config, status, say, wallchan';
$irc->yield( privmsg => $replyto, $answer );
}
$irc->yield( privmsg => $replyto, $answer );
}
+ if ($string eq 'say') {
+ my $answer = "Use ?say #channel message";
+ # translate message
+ $answer = translate_text_for_channel($replyto, 'help_general_line_say', $answer);
+ $irc->yield( privmsg => $replyto, $answer );
+ }
+
return '';
}