Bug - Not A Bug Update faxbots?

Malurth

Member
The faxbot command is, in a sense, bugged, in that nowadays it almost never works. It pings EasyFax, waits 60 seconds, and then times out, approximately 99% of the time. Technically it is not bugged, as it is doing what it is supposed to do and really EasyFax is the one dropping the ball, but still, the command basically is just a "wait 60 seconds and then abort" right now, so I'll opt to call it a bug for the purposes of a thread prefix.

It's possible there's a way to change the default faxbot or the timeout duration, but I poked around and couldn't find anything. If I could just swap the default to CheeseFax, this would not be an issue, as CheeseFax always responds to me within about 10 seconds. As it stands, my run-once daily automation script requires me to instead manually retrieve and fight the fax monster every single day since the command always fails, which is quite irritating :<
 

fronobulax

Developer
Staff member
Is chat open before you request the fax? Easyfax has been working just fine for me. The behavior you described used to happen to me a lot and then I realized I had gotten the fax I expected but KoLmafia could not report success because the success message was only available via chat which I never use or open.
 

AlbinoRhino

Active member
Is chat open before you request the fax? Easyfax has been working just fine for me. The behavior you described used to happen to me a lot and then I realized I had gotten the fax I expected but KoLmafia could not report success because the success message was only available via chat which I never use or open.

I had the same experience.
 

Veracity

Developer
Staff member
Works every time for me. As stated above, it cannot work if you do not have a chat window open, either in KoLmafia or in the browser.
 

fronobulax

Developer
Staff member
it cannot work

My experience has been that it will still attempt to get the fax, whether the chat is open, or not. However, in the absence of chat, the only way to know that it worked and you got the expected monster, is to actually visit the fax machine and receive a fax. There were many times when I did that and the expected monster was there. But the certainty provided by having chat open is worth it.

There is discussion elsewhere to the effect that there is no easy way to script opening and closing chat. I personally manually open it prior to a fax operation and manually close it after. Other folks just make chat a tab or window that opens at start up. I don't do that because of an anecdotal, undocumented and unresearched belief that on my machine having chat open eventually causes problems related to high resource usage. But that is me. No one else has reported something similar enough to make me dig in again and see if there really is something to my belief.
 

Veracity

Developer
Staff member
By "it cannot work", I was talking about the faxbot command, which "cannot work" at recognizing when the fax has arrived without chat being open.

The reason it tries, whether or not you have chat open, is that we have no way of knowing that chat is currently open in the Relay Browser. We can tell if you have the chat GUI open in KoLmafia, but some people prefer to use the browser's chat. Therefore, we ask for the fax regardless and assume that the user knows you have to have chat open somewhere.
 

Veracity

Developer
Staff member
I suppose the "fax receive" CLI command could print an informative message reminding you that chat must be open, before sending.

Note that the FaxRequestFrame does this:

Code:
		// Make sure we can receive chat messages, either via KoLmafia chat or in the Relay Browser.
		if ( !( ChatManager.isRunning() || true ) )
		{
			FaxRequestFrame.statusMessage = "You must be in chat so we can receive messages from " + botName;
			KoLmafia.updateDisplay( FaxRequestFrame.statusMessage );
			return false;
		}
I don't know if that is 100% reliable; I'm pretty sure that if you open chat and close it, ChatManager will still be running.
Which is why there is "|| true" following the check; you'll never see that message.
 
The faxbot command is, in a sense, bugged, in that nowadays it almost never works. It pings EasyFax, waits 60 seconds, and then times out, approximately 99% of the time. Technically it is not bugged, as it is doing what it is supposed to do and really EasyFax is the one dropping the ball, but still, the command basically is just a "wait 60 seconds and then abort" right now, so I'll opt to call it a bug for the purposes of a thread prefix.

It's possible there's a way to change the default faxbot or the timeout duration, but I poked around and couldn't find anything. If I could just swap the default to CheeseFax, this would not be an issue, as CheeseFax always responds to me within about 10 seconds. As it stands, my run-once daily automation script requires me to instead manually retrieve and fight the fax monster every single day since the command always fails, which is quite irritating :<

If you are requesting right after rollover, EasyFax is simply not online (I think that can't happen with the faxbot command, but I'm not 100% sure).

Regarding chat being open, I have code in cc_ascend that works around chat having to be open.
 

Malurth

Member
Hm. I see. I was unaware of this limitation, though in retrospect it makes sense.

I suppose I'll have to scour cc_ascend to figure out how to work around it, then. Thanks for the info.
 

taltamir

Member
Works every time for me. As stated above, it cannot work if you do not have a chat window open, either in KoLmafia or in the browser.
In this case the bug is that it waits for 60 seconds and then timing out.
Instead it should immediately print to the CLI an error message that says "chat window not open, you must enter chat to use faxbot feature"
 

Veracity

Developer
Staff member
Tell me how we can detect if you have the chat window open in the Relay Browser.
I'm all ears.
 

AlbinoRhino

Active member
Tell me how we can detect if you have the chat window open in the Relay Browser.
I'm all ears.

Could mafia issue some innocuous command like "/channels" and see is if it quickly gets a response? And, if not, assume the browser chat is closed and open the mafia chat?

I don't know what all is possible with JAVA but with Javascript you could cycle through the frames and look for a location of "mchat.php" (and maybe those older chat scripts which I don't remember the names of anymore). Or maybe, just look for chatlaunch.php, and if found, assume it is closed.

Not that I care...but it sounds like an interesting problem to solve!
 

Veracity

Developer
Staff member
I was hoping for a solution based on KoLmafia's internal state which would not require a server hit.

KoLmafia's ChatManager is open if you have the GUI Chat Frame open - or if the Relay Browser is open and chat requests/responses come from the browser. In both of those cases, we have a ChatPoller running to listen for asynchronous chat stuff coming from KoL.

You can close the chat frame in the browser and, as I understand it, KoLmafia can't tell, since it's done via Javascript in the browser itself.

Additionally, I believe (having not looked at the code in years), when you issue a Chat command in the GUI, it also opens the ChatManager if necessary, but doesn't start a ChatPoller. Some commands return right away and we get the results. Others essentially redirect into a different Request - things like "/eat" or "/equip".

The ideal solution - which I couldn't figure out years ago when I added FaxBot support - would know exactly when we have a ChatPoller running to examine the chat responses coming asynchronously from KoL and detect when the FaxBot says "here it is" or "nopers".

I am probably the only remaining "expert" on KoLmafia's chat support, since I am the one who integrated KoLmafia's chat support with mchat, many years ago, but since I don't chat, I haven't been motivated to keep that knowledge up to date - or to dive deep enough to fully come up with a solution for this particular issue.

I will look at any proffered patches, but am unlikely to spend time working on it in my own time; simply making sure the chat window is open when I ask for a fax is good enough for my needs.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
Obviously you're much more familiar with this than I am but would it be possible to have a piece of JS running in the main window that watches the chatpane frame to see when it's title changes (or some other factor) and then hit something like "http://127.0.0.1:60080/KoLmafia/submitCommand?cmd=relay_chat open&pwd" (or "relay_chat closed" of course). I'd be happy to write it up if you think it sounds sensible.
 

xKiv

Active member
The regular requests to newchatmessages.php are not a good enough indicator?
(assuming that "new" chat is the only chat good enough for our purposes)
 
Unless this stuff if going to open a chat window and handle your chats for you (which is not ideal as that can wipe PMs), I am not sure how this solves the issue. The 60 second timeout might be considered a "hack" but it works (it could be faster sure, but the faxbot itself can be delayed so you can't really do much about it), you ultimately still need a timeout.

If Mafia could detect that the chat window was open and rejected the fax request until it was open, that breaks implementations that don't or can't open a chat window (they'll have to revert to visit_url and timers).

I'm not going to say I wasn't initially frustrated the first time I encountered this and was like "why do I need chat open? why can't it do it for me?". But it makes sense and as currently implemented, it still makes the request regardless of chat opened status - this is the important part.
 

taltamir

Member
If I am not mistaken, should it not be possible to have mafia aware of that initial time where you manually click the button to enter chat in the first place (after all, something must be launching the current existing code)? If it is, then one could make deductions on the current status.

A. If the player, after logging in to mafia, never clicked to enter chat, then chat has to be closed
B. If the player, after opening a new relay window via the button on mafia that does that has not entered chat, then the chat has to be closed
C. If the player has at some point in the past, during the current session, clicked on the button to enter chat, then the chat status is unknown, but likely to be open. unless the player closed the relay browser and is playing purely in mafia without a browser, or something else happened to log them out of chat but not mafia. Or the chat login failed after the button was clicked.

Basically set bool to false on login, and to true on launching chat. If bool is on true, then chat status is unknown, but probably open. If bool is false, then chat is certain to be closed.
 
Last edited:

fronobulax

Developer
Staff member
Whatever happens it will be tested with a character with access to a fax but had not visited the Altar of Literacy :)
 
If I am not mistaken, should it not be possible to have mafia aware of that initial time where you manually click the button to enter chat in the first place (after all, something must be launching the current existing code)? If it is, then one could make deductions on the current status.

A. If the player, after logging in to mafia, never clicked to enter chat, then chat has to be closed
B. If the player, after opening a new relay window via the button on mafia that does that has not entered chat, then the chat has to be closed
C. If the player has at some point in the past, during the current session, clicked on the button to enter chat, then the chat status is unknown, but likely to be open. unless the player closed the relay browser and is playing purely in mafia without a browser, or something else happened to log them out of chat but not mafia. Or the chat login failed after the button was clicked.

Basically set bool to false on login, and to true on launching chat. If bool is on true, then chat status is unknown, but probably open. If bool is false, then chat is certain to be closed.

I have accounts where I can guarantee that it will be false according to this paradigm and some of them run in places where I can't open chat (no GUI, headless). I'd really like if this doesn't break that things already work.
 
Top