$main::statistics{'command_counter_join'} = 0;
$main::statistics{'command_counter_leave'} = 0;
$main::statistics{'command_access_denied'} = 0;
+ $main::statistics{'command_access_lost'} = 0;
$main::statistics{'database_connects'} = 0;
$main::statistics{'database_queries'} = 0;
return 1;
} elsif ($command eq 'leave') {
return 1;
+ } elsif ($command eq 'lost') {
+ return 1;
}
return 0;
case('leave') {
return handle_command_leave($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
+ case('lost') {
+ $main::statistics{'command_counter_lost'}++;
+ return handle_command_lost($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
+ }
}
}
+# handle_command_lost()
+#
+# command handler for the 'lost' 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_lost {
+ 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;
+
+
+ # 'lost' goes to the command channel only
+ if (lc($channel) eq lc($irc->nick_name())) {
+ return 'The "lost" command is only allowed in the command channel';
+ }
+ if (lc($channel) ne lc(config_get_key2('bot', 'commandchannel'))) {
+ return 'The "lost" command is only allowed in the command channel';
+ }
+
+
+ my $query = "SELECT url FROM docbot_url WHERE id NOT IN (SELECT kurl FROM docbot_key) ORDER BY id";
+ my $st = $main::db->query($query);
+ if (!defined($st)) {
+ my $answer = "Database error";
+ # translate error message
+ $answer = translate_text_for_channel($channel, 'database_error', $answer);
+ return $answer;
+ }
+ my $rows = $st->rows;
+ if ($rows == 0) {
+ my $answer = "No unconnected urls in database";
+ return $answer;
+ }
+
+
+ # fetch the result
+ my @rows = ();
+ while (my @row = $st->fetchrow_array) {
+ push(@rows, $row[0]);
+ }
+
+
+ my @lines = ();
+ my $maxresults = config_get_key2('search', 'maxresults');
+ if ($maxresults == 0) {
+ # set a reasonable high default
+ $maxresults = 50;
+ }
+ if ($maxresults < 20) {
+ $maxresults = 20;
+ }
+ my $maxwrap = config_get_key2('search', 'maxwrap');
+ for (my $a = 1; $a <= int($maxresults / $maxwrap); $a++) {
+ my @line = ();
+ for (my $b = 1; $b <= $maxwrap; $b++) {
+ if (defined($rows[0])) {
+ push(@line, shift(@rows));
+ }
+ }
+ if (scalar(@line) > 0) {
+ push(@lines, join(" :: ", @line));
+ }
+ }
+
+ if (scalar(@lines) > 0) {
+ $irc->yield( privmsg => $channel, "$rows unconnected urls in database:" );
+ foreach my $line (@lines) {
+ $irc->yield( privmsg => $channel, $line );
+ }
+ }
+
+
+ return '';
+}
+
+
# handle_command_wallchan()
#
# command handler for the 'wallchan' command
$irc->yield( privmsg => $replyto, $answer );
}
+ if ($string eq 'lost') {
+ my $answer = "Use ?lost";
+ # translate message
+ $answer = translate_text_for_channel($replyto, 'help_general_line_lost', $answer);
+ $irc->yield( privmsg => $replyto, $answer );
+ }
+
return '';
}