Recap from another thread (
"...problem is the AFK command sent from the script is immediatley followed by a single empty line, which cancels the AFK, sometimes sending me into a loop."
I tried the suggestion you mentioned in the other thread
(
A single empty line is still being sent from somewhere when I call my AFK script. I use an alias regex
Here's what happens:
- I type
- Alias calls subroutine
- Script writes a note containing timestamp and notice of going AFK, including any reason.
- Script sets variable
- Script sets status line to show AFK set and reason if any.
- Script sends
- Log files show something sends a single empty line causing the return noted two items down.
- Talker server confirms AFK command.
- Talker server reports returning from AFK.
- Script is triggered on return text to display a note of timestamp and return notice, clear status line and delete
This is a sample of the output. Script notes begin with a timestamp.
This is a sample of the log file. All text in/out has a timestamp followed by either
It should be noted above that the command sent from within the script is not displayed in the log file.
Below is my GoAFK subroutine, written in Perl.
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=369 ):"...problem is the AFK command sent from the script is immediatley followed by a single empty line, which cancels the AFK, sometimes sending me into a loop."
I tried the suggestion you mentioned in the other thread
(
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=369 ). It was no help. For one, I don't think packet debug worked, even though it was shown as enabled. I didn't see anything that looked like a debug message anywhere.A single empty line is still being sent from somewhere when I call my AFK script. I use an alias regex
^\.goafk(.*)$ to call the script to go AFK, with or without a reason. I use one subroutine to handle going AFK, testing AFK when an idle warning pops up and returning from AFK.Here's what happens:
- I type
.goafk or .goafk test reason.- Alias calls subroutine
GoAFK with the label goafk.- Script writes a note containing timestamp and notice of going AFK, including any reason.
- Script sets variable
vAFK to reason or empty string if none.- Script sets status line to show AFK set and reason if any.
- Script sends
.afk[ reason], where [ reason] is optional, to the talker server.- Log files show something sends a single empty line causing the return noted two items down.
- Talker server confirms AFK command.
- Talker server reports returning from AFK.
- Script is triggered on return text to display a note of timestamp and return notice, clear status line and delete
vAFK variable.This is a sample of the output. Script notes begin with a timestamp.
[12:35:04am] AFK
You are now AFK, press <return> to reset.
You are no longer AFK.
[12:35:04am] AFK: Return!
This is a sample of the log file. All text in/out has a timestamp followed by either
<= for inbound (to me) or => for outbound (to server). Script notes already have a timestamp.
[12:35:04am] AFK
[00:35:04] =>
[00:35:04] <= You are now AFK, press <return> to reset.
[00:35:04] <= You are no longer AFK.
[12:35:04am] AFK: Return!
It should be noted above that the command sent from within the script is not displayed in the log file.
Below is my GoAFK subroutine, written in Perl.
sub GoAFK {
my($name, $output, $cards) = @_;
my($jAFK, $jCard);
if ($name eq 'goafk') {
$jCard = substr(@{$cards}[0],1);
chomp($jCard);
if ($jCard eq '') {
$world->note(&myTime . " AFK");
$world->setVariable("vAFK", "");
$world->setStatus(" --AFK-- --AFK-- --AFK-- --AFK-- --AFK--");
$world->send(".afk");
} else {
$world->note(&myTime . " AFK: $jCard");
$world->setVariable("vAFK", $jCard);
$world->setStatus(" --AFK-- --AFK-- [ $jCard ] --AFK-- --AFK--");
$world->send(".afk $jCard");
}
} elsif ($name eq 'testafk') {
$world->send(".who");
$jAFK = $world->getVariable("vAFK");
if ($jAFK eq '' || !defined($jAFK)) {
$world->setStatus(" --AFK-- --AFK-- --AFK-- --AFK-- --AFK--");
$world->send(".afk");
} else {
$world->setStatus(" --AFK-- --AFK-- [ $jAFK ] --AFK-- --AFK--");
$world->send(".afk $jAFK");
}
} elsif ($name eq 'afkreturn') {
$world->note(&myTime . " AFK: Return!");
$world->deleteVariable("vAFK");
$world->setStatus("");
} else {
$world->note(&myTime . " GoAFK: Unknown label/name: $name");
}
}