In response to https://kolmafia.us/showthread.php?23587-Checking-Easyfax-doesn-t-time-out I started looking at the code.
My specific concern was the ash command faxbot() but some of these comments apply to fax support in general.
At present faxbot() will only request a monster from the first faxbot that has it. It returns true if a monster was successfully faxed but false does not mean the attempt was unsuccessful. Sometimes false means the attempt was made and definitely failed but sometimes it just means the attempt was made and the status is unknown. Since the faxbot command checks for a photocopied monster in inventory and offers the chance to dump the fax or abort, several scripts ignore the return from faxbot() and instead detect success or failure from the presence of the photocopied monster.
There is dead code that once aborted the command if chat was not running but that code is disabled, presumably in 2012.
The faxbot online status is based upon /whois and is not changed by the non-success of fax attempts. This is as it should be IMO.
The faxbot() command iterates over all bots and returns the result from the first one. An attempt (temp code change) was made to check the next bot when the first one failed, but if chat was not running the result was getting a fax from one bot, not knowing the status, and then getting a fax from the next bot. (Tangentially, I did not see the expected prompt from a photocopied monster present so I don't know whether I don't quite understand the code or what so there is some work to be done).
AFAIK there is no easy way for a script writer to detect that a bot did not return the desired fax and try a different bot.
I can see several possibilities.
Status Quo - leave things as they are.
Add ash functions so that a scripter knows which bots are available and whether a monster is available from a specific bot. This essentially moves the iterate over bots until success or end of list from mafia to the script.
Create int robust_faxbot() that returns 1 if the requested monster was faxed, 0 if there is already a photocopied monster (possibly unknown) in inventory and -1 if it failed.
Modify faxbot() so that it checks other bots in case of failure and uses the presence/absence of the photocopied monster to define success/failure.
And there are always things I have not thought about.
I am inclined towards the latter but it will make some code in some scripts unnecessary.
This is essentially my response to an unmade Feature Request to try all known bots before failing to get a fax.
Thoughts? Comments?
My specific concern was the ash command faxbot() but some of these comments apply to fax support in general.
At present faxbot() will only request a monster from the first faxbot that has it. It returns true if a monster was successfully faxed but false does not mean the attempt was unsuccessful. Sometimes false means the attempt was made and definitely failed but sometimes it just means the attempt was made and the status is unknown. Since the faxbot command checks for a photocopied monster in inventory and offers the chance to dump the fax or abort, several scripts ignore the return from faxbot() and instead detect success or failure from the presence of the photocopied monster.
There is dead code that once aborted the command if chat was not running but that code is disabled, presumably in 2012.
The faxbot online status is based upon /whois and is not changed by the non-success of fax attempts. This is as it should be IMO.
The faxbot() command iterates over all bots and returns the result from the first one. An attempt (temp code change) was made to check the next bot when the first one failed, but if chat was not running the result was getting a fax from one bot, not knowing the status, and then getting a fax from the next bot. (Tangentially, I did not see the expected prompt from a photocopied monster present so I don't know whether I don't quite understand the code or what so there is some work to be done).
AFAIK there is no easy way for a script writer to detect that a bot did not return the desired fax and try a different bot.
I can see several possibilities.
Status Quo - leave things as they are.
Add ash functions so that a scripter knows which bots are available and whether a monster is available from a specific bot. This essentially moves the iterate over bots until success or end of list from mafia to the script.
Create int robust_faxbot() that returns 1 if the requested monster was faxed, 0 if there is already a photocopied monster (possibly unknown) in inventory and -1 if it failed.
Modify faxbot() so that it checks other bots in case of failure and uses the presence/absence of the photocopied monster to define success/failure.
And there are always things I have not thought about.
I am inclined towards the latter but it will make some code in some scripts unnecessary.
This is essentially my response to an unmade Feature Request to try all known bots before failing to get a fax.
Thoughts? Comments?