Mysterious empty line being sent from somewhere

Posted by 1of10 on Mon 10 Dec 2001 02:18 AM — 12 posts, 46,204 views.

Canada #0
Recap from another thread ( 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");
	}
}
Amended on Mon 10 Dec 2001 02:20 AM by 1of10
Australia Forum Administrator #1
There was a problem with blank lines, see the release notes for version 3.12 ...

1. Fixed a bug where every line you sent to the MUD was inadvertently followed by a blank line. This made it very hard to log into MUDs that prompted for a character name and password, as the password was always blank.


I suggest you download the latest version, and see if that fixes the problem.
Canada #2
I have the latest version: 3.17. I check the website often for updates. Perhaps two bugs the same? One for typed text, one for script sent text? This is only a problem with a script. If I go AFK on my own, using the talker server command myself, there is no problem.
Australia Forum Administrator #3
Yes, if there was a bug it might be the same one, however when I do the packet debug (see earlier thread) and don't see two newlines, I can't confirm there is a problem.

I repeat my offer that you send me the world file, and tell me what to type, so I can see what is happening.
Canada #4
I outlined exactly what is done already. Everything is handled by the one script I posted in the original message. I type
.goafk[ reason]
to call the script to send the command to the talker server.

I will send stripped copies of the world file and script file in an email.
Instructions can be found in the original message.
Australia Forum Administrator #5
Yes, I see what you mean. It appears that an alias will always send a blank line, so what is happening is that the script does its stuff, then the alias contents (empty in your case) is taken, a newline appended, and then the alias sent.

I have added that as bug #428.

I will have to omit the blank line if the alias output is empty, and hope that this does not affect anyone else who is relying on it.
Australia Forum Administrator #6
While you are waiting for the next version of MUSHclient to be released, I have thought of a work-around for you. :)

Instead of "send" use "queue" to go AFK. ie.


$world->queue(".afk $jCard");


Make sure your "speedwalk" delay is something other than zero.

This will change the order things are done in.

Currently:

  • You type ".goafk"
  • The script does: $world->send(".afk $jCard");
  • The text ".afk (whatever)" is sent to the MUD
  • The blank alias sends a newline
  • The newline cancels AFK mode


Now what will happen is:

  • You type ".goafk"
  • The script does: $world->queue(".afk $jCard");
  • The blank alias sends a newline
  • The newline does not have much affect
  • After a delay (say, one second), the text ".afk (whatever)" is sent to the MUD
  • You stay in AFK mode




Canada #7
I tried the work-around you suggested, but that didn't help. No error was returned when the script file was reloaded... No error was returned when I intentionally misspelled queue, to see if it would catch it. The queue doesn't appear to do anything at all.

I'll wait for the next version. I've gone this long without a custom AFK command. I can go longer...
Canada #8
I got the queue working. I looked through the function list and discovered the queue command requires two variables: the message and a true/false for output echo. However, it was still no help. The same thing happens using queue as when using send. The only difference is the time delay.


[11:44:31pm] AFK
[23:44:31] => 
[23:44:32] <= You are now AFK, press <return> to reset.
[23:44:34] <= You are no longer AFK.
[11:44:34pm] AFK: Return!
Australia Forum Administrator #9
So much for my brilliant idea! :(

It seems the same bug infests the queued command sending, so that the queued command is followed by a final newline.

Looks like you'll need to wait for the bugfix, sorry.

I have amended the bug report to include this problem as well.
Amended on Sun 16 Dec 2001 10:16 PM by Nick Gammon
Canada #10
Hey, it was a good idea. I'm happy enough that there's a solution in the works. Just knowing eventually my script and custom command will work is good enough for me. MUSHclient is still the best chat/MU* client I've ever used. I'm glad I actually legally registered it.
Canada #11
I just downloaded 3.20 and tested my AFK script.

I'm VERY pleased to say it works perfectly! Bug #428 has been fixed. :)

You're wonderful! MUSHclient is wonderful! Registering this software was worth it. :)

Thank you.