Feature - Implemented Add new Fax(ing) bots

Veracity

Developer
Staff member
I was going to say "don't we check that?" but when I look at FaxRequestFrame.java, I see:

Code:
		// Make sure we can receive chat messages, either via KoLmafia chat or in the Relay Browser.
		if ( !( ChatManager.isRunning() || true ) )
but I see that we actually don't require you to be in chat. The comment to revision 8860 says:

You have to be in chat for us to successfully receive the response. I know how
to check if you are in KoLmafia chat, but not how to check if you are in chat
in the Relay Browser, so we don't enforce this, yet
So, I guess we've never actually enforced this.
 

Veracity

Developer
Staff member
Is this done? The GUI seems to work well, even for the art teacher. So does the ASH function:

> ash faxbot( $monster[ art teacher ] )

Changing "art teacher" to "François Verte\, Art Teacher" would get rid of this message ()
Configuring faxable monsters.
Configuring FaxBot (2194132)
Configuring FaustBot (2504770)
Configuring Easyfax (2504737)
Faxable monster lists fetched.
Visiting Fax Machine in clan VIP lounge
Sending a fax.
You load your photocopied monster in the fax machine.
Asking Easyfax to send a fax of François Verte, Art Teacher: François Verte, Art Teacher
Receiving a fax.
You acquire an item: photocopied monster
You receive a photocopied François Verte, Art Teacher from the fax machine.
Returned: true
I guess the question is: Is the CLI command done?
 

lostcalpolydude

Developer
Staff member
The only extra thing I would add is partial name matching. I think I need to change the list of commands to be stored with canonical names to reasonably do that (my plan was to use StringUtilities.getMatchingNames() ), and I don't know how that would affect the ASH or GUI functionality. If not at all, then I could take care of that after work today.
 

Veracity

Developer
Staff member
I think I need to change the list of commands to be stored with canonical names to reasonably do that (my plan was to use StringUtilities.getMatchingNames()
Well, what do you mean by "list of commands"?

Each FaxBot has a SortedListModel of Monster objects.
Each Monster has a name, and actualName, a command, and a category, all of which are taken straight from the XML config file.
Each FaxBot also has two Maps which go from canonicalized actualName to monster.name or monster.command.
The ASH command uses those to translate from a $monster to appropriate monster name/command.

Now, the CLI command lets you type a "command" and uses the FaxBot.hasCommand method to see if it is valid. If so, it passes the command (as entered by the user) to the FaxBot, with no knowledge of just what monster will be requested.

Seems to me there could be some refactoring in FaxBot:

Monster getMonsterByActualName( String name )
Monster getMonsterByCommand( String command )

They both return null if no monster matches or the Monster object, otherwise.

Instead of have the caller pass monster.name and monster.command to
FaxRequestFrame.requestFax( final String botName, final String monster, final String command, final boolean checkOnline ),

It would pass the looked up Monster object to
FaxRequestFrame.requestFax( final String botName, final Monster monster, final boolean checkOnline ),
which would extract monster.name and monster.command.

Given the above, the FaxBot object would have two data structures to aid Monster getMonsterByActualName( String name ) and Monster getMonsterByCommand( String command ). Instead of:

private final Map<String, String> monsterByActualName = new HashMap<String, String>();
private final Map<String, String> commandByActualName = new HashMap<String, String>();

it would build:

private final Map<String, Monster> monsterByActualName = new HashMap<String, Monster>();
private final Map<String, Monster> monsterByCommand = new HashMap<String, Monster>();
private String[] canonicalizedCommands

and the CLI command would call getMonsterByCommand( String command ) with the command substring, it would look it up using StringUtilities.getMatchingNames, as you suggest, and if there is a unique match, it would look up the full command in monsterByCommand and return that.

Huh. Well, I'll see if I can do the initial refactoring for you, at least. ;)
 

lostcalpolydude

Developer
Staff member
That looks like it would take care of things. I wrote up some code last week to handle partial matches for bots that allow it, but never sorted out "adventurer echo" matching for easyfax instead of "Adventurer echo". It looks like that won't even be necessary with that refactoring.
 

Veracity

Developer
Staff member
Well, try revision 14173. I refactored the data, as suggested, and wrote a method for the FaxbotCommand to use

Code:
		public List findMatchingCommands( final String command )
		{
			String canonical = StringUtilities.getCanonicalName( command );
			return StringUtilities.getMatchingNames( this.canonicalCommands, canonical );
		}
This leaves it up to the command to decide what to do if there are multiple commands (ambiguous). At the moment, the command looks for the first bot which has exactly one matching command; it skips bots with 0 matches and aborts if there is more than one match. It does not look for ambiguity across bots - a command matches in bot A and also in bot B. That may not actually matter. And, interestingly enough, if you search for "art teacher", it seems to find "art_teacher" in Faxbot, not a substring of the full monster name from easyfax.

I'll leave it to you to look at this and decide if anything more needs to be done to it.
 

lostcalpolydude

Developer
Staff member
That looks good to me. It adds partial commands through the CLI command even for bots that don't support it, which is better than what I had planned. If one bot has multiple matches and a later one on the list only has one match, the later one won't be checked and used, but that falls somewhere between okay and the only sane way to handle it (the longer I think about it, the more I lean toward the latter).
 

Veracity

Developer
Staff member
Thanks. Revision 14176 builds the command -> Monster and name -> Monster maps more sensibly when configuring the faxbots, but is otherwise unchanged.
 

Crowther

Active member
[12:10] Veracity: François Verte, Art Teacher
[12:10] Easyfax: Your fax is ready.
[12:14] Veracity: François Verte, Art Teacher
[12:14] Easyfax: Your fax is ready.
[13:48] Veracity: François Verte, Art Teacher
[13:48] Easyfax: Your fax is ready.
[13:49] Veracity: François Verte, Art Teacher
[13:49] Easyfax: Your fax is ready.
[17:23] Veracity: François Verte, Art Teacher
[17:23] Easyfax: Your fax is ready.
Anything I can do at my end? The only outstanding issue on my list is that the art teacher's name is wrong in the k-mail list Easyfax sends. However, I have confirmed that that is a KoL bug. I sent a message to myself with that monster's name as it would cut and paste from KoL and the message I received was different.
 
Last edited:

Veracity

Developer
Staff member
You are fine. Easyfax behaves behaves exactly as I would expect - serving this particular fax from Grll Power, we expect. I have no problem getting the art teacher via the GUI or the ASH function at least. Thanks!
 
Top