# - add new statistic counter in init_statistics()
# - output command statistic in handle_command_status()
# - add the command to is_valid_command(), is_valid_operator_command() and/or is_valid_admin_command()
+# - add help for the command in handle_command_help()
# - add any required translation to docbot.conf
}
case('help') {
$main::statistics{'command_counter_help'}++;
+ return handle_command_help($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
case('info') {
$main::statistics{'command_counter_info'}++;
}
+# handle_command_help()
+#
+# command handler for the 'help' 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_help {
+ 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;
+
+
+ my $session = find_irc_session($irc);
+
+
+ if (lc($channel) eq lc($irc->nick_name())) {
+ print_msg("Help issued: '$string', by $nick", DEBUG2);
+ } else {
+ print_msg("Help issued: '$string', by $nick in $channel", DEBUG2);
+ }
+
+
+ # remove spaces at beginning and end
+ $string =~ s/^[\s\t]+//gs;
+ $string =~ s/[\s\t]+$//gs;
+
+
+ # find out where to reply the answer
+ my $replyto = $channel;
+ if (lc($channel) eq lc($irc->nick_name())) {
+ $replyto = $nick;
+ } elsif ($string =~ /^(.+)\s+>\s+(\w+)/i) {
+ if (grep(/^$channel$/i, find_nick($heap, $2, $session))) {
+ $string = $1;
+ $replyto = $2;
+ } else {
+ return '';
+ }
+ }
+
+
+ if (length($string) == 0) {
+ my $answer = "General help";
+ # translate message
+ $answer = translate_text_for_channel($replyto, 'help_general_line_1', $answer);
+ $irc->yield( privmsg => $replyto, $answer . ':' );
+
+ $answer = "Start a search with two question marks, followed by the search term";
+ # translate message
+ $answer = translate_text_for_channel($replyto, 'help_general_line_2', $answer);
+ $irc->yield( privmsg => $replyto, $answer );
+
+ $answer = "The following commands are also available";
+ # translate message
+ $answer = translate_text_for_channel($replyto, 'help_general_line_3', $answer);
+ $answer .= ': ';
+ $answer .= 'search, help, info, learn, forget, config, status, wallchan';
+ $irc->yield( privmsg => $replyto, $answer );
+ }
+
+
+ return '';
+}
+
+
######################################################################
# IRC functions
######################################################################