Bug - Fixed "online?" button does not timein correctly

Veracity

Developer
Staff member
The Request Buff frame (and the Request Fax frame) have an "online?" button. When you press it, this calls KoLmafia.isPlayerOnline( name ), which calls KoLmafia.whoisPlayer( name), which submits a request to "submitnewchat.php?playerid=xxx&pwd=yyy&graf=/whois name" (URL encoded, of course).

If the response is non-null and contains "This player is currently", the player is deemed to be online. Otherwise, probably not.

If you have timed out before pressing that button, KoLmafia does NOT time you back in and resubmit the request. Instead, it reports that the bot is "probably not online".
 

lostcalpolydude

Developer
Staff member
A while back I made chat requests not timein (by adding GenericRequest.ignoreChatRequest), so that someone leaving mafia open on one machine (at work, perhaps) and then trying to log in elsewhere could actually do so without a password reset. Obviously this is a chat request...

This could be fixed by adding another boolean, and switching its value at the start and end of whoisPlayer(), and then checking for that when deciding whether to timein. That boolean would need to be added to other functions too (a quick check brings up who_clan() as an ASH function), and I don't think every place would be caught on the first pass. There might be a better fix than that.
 

Veracity

Developer
Staff member
Yeah. I just looked at it in Eclipse and saw the following code:

Code:
		if ( this.redirectLocation.startsWith( "login.php" ) )
		{
			if ( this instanceof LoginRequest )
			{
				this.constructURLString( this.redirectLocation, false );
				return false;
			}

			if ( this.formURLString.startsWith( "logout.php" ) )
			{
				return true;
			}

			if ( this.isChatRequest )
			{
				RequestLogger.printLine( "You are logged out.  Chat will no longer update." );
				GenericRequest.ignoreChatRequest = true;
				return false;
			}

			String oldpwd = GenericRequest.passwordHashValue;
			if ( LoginRequest.executeTimeInRequest( this.getURLString(), this.redirectLocation ) )
			{
				if ( this.data.isEmpty() )
				{
					String newpwd = GenericRequest.passwordHashValue;
					this.formURLString = StringUtilities.singleStringReplace( this.formURLString, oldpwd, newpwd );
					this.formURL = null;
				}
				else
				{
					this.dataChanged = true;
				}
				return false;
			}

			return true;
		}
And, sure enough, I saw "You are logged out. Chat will no longer update." - four times! - in the gCLI.

I was wondering about the motivation for this, since I couldn't understand why you'd ever time out, if you were in chat, since chat polls often enough to keep KoL from logging you out, but forcing a logout by logging in from another machine would do it.

As you comment, we have a variety of internal functions to do things via chat, even if you are not actually running chat.

Perhaps we could have a new class - InternalChatRequest - either off of ChatRequest or GenericRequest, which builds the URL, complete with graf, and then sets this.isChatRequest to false. That means that these internal requests will get logged in the DEBUG log, whether or not you have "chat" message logging enabled, which seems reasonable, since we are not using them to actually "chat" per se.
 

Veracity

Developer
Staff member
It was easy to make such a class and make KoLmafia.whoisPlayer and RuntimeLibrary.who_clan use it.
I'm now waiting to time out to verify that the online? button will time me in, as expected.
If so, I'll submit this.
 

Veracity

Developer
Staff member
Revision 16006 uses InternalChatRequest for KoLmafia.whoisPlayer and RuntimeLibrary.who_clan and will therefore time in, as needed.
 
Top