}
case('status') {
$main::statistics{'command_counter_status'}++;
+ return handle_command_status($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
}
-
return '';
}
+# handle_command_status()
+#
+# command handler for the 'status' 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_status {
+ 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;
+
+
+ # 'status' goes to the command channel only
+ if (lc($channel) eq lc($irc->nick_name())) {
+ return 'The "status" command is only allowed in the command channel';
+ }
+ if (lc($channel) ne lc(config_get_key2('bot', 'commandchannel'))) {
+ return 'The "status" command is only allowed in the command channel';
+ }
+
+
+ $irc->yield( privmsg => $channel, 'Bot uptime: ' . format_time_short_exact(time() - $main::statistics{'docbot_start'}) );
+ $irc->yield( privmsg => $channel, 'Number of parallel sessions: ' . scalar(keys(%main::sessions)) );
+ my @nicks = ();
+ my @channels = ();
+ foreach my $tmp_session (keys(%main::sessions)) {
+ push(@nicks, $main::sessions{$tmp_session}{'session'}->nick_name());
+ push(@channels, @{$main::sessions{$tmp_session}{'joined_channels'}});
+ }
+ $irc->yield( privmsg => $channel, 'Nick names: ' . join(", ", @nicks) );
+ $irc->yield( privmsg => $channel, 'Joined channels: ' . join(", ", @channels) );
+ $irc->yield( privmsg => $channel, 'Number of connects: ' . $main::statistics{'connects'} );
+ my @commands = ();
+ push(@commands, 'search: ' . $main::statistics{'command_counter_search'});
+ push(@commands, 'help: ' . $main::statistics{'command_counter_help'});
+ push(@commands, 'info: ' . $main::statistics{'command_counter_info'});
+ push(@commands, 'learn: ' . $main::statistics{'command_counter_learn'});
+ push(@commands, 'forget: ' . $main::statistics{'command_counter_forget'});
+ push(@commands, 'config: ' . $main::statistics{'command_counter_config'});
+ push(@commands, 'status: ' . $main::statistics{'command_counter_status'});
+ $irc->yield( privmsg => $channel, 'Number of executed commands: ' . join(", ", @commands) );
+ $irc->yield( privmsg => $channel, 'Number of denied requests: ' . $main::statistics{'command_access_denied'} );
+
+
+ return '';
+}
+
+