Returning response of chat commands

Veracity

Developer
Staff member
I understand that people are trying to spade where the invisible string comes from and want to script it using /count, since it just appears in inventory ... sometimes ... with no announcement.

Code:
[color=green]> ash slash_count( $item[ sugar sheet ] )[/color]

Returned: 2391

[color=green]> ash slash_count( $item[ invisible string ] )[/color]

Returned: 0
Seems like this could do it. For amusement, I also coded a more general function:

Code:
[color=green]> ash slash_command( "whois", "Jick" )[/color]

Returned: [color=green]Jick (#1), Jick-Or-Treat! (In Ronin)[/color]

[color=green]> ash slash_command( "count", "sugar sheet" )[/color]

Returned: [color=green]You have 2391 sugar sheets.[/color]

[color=green]> ash slash_command( "pull", "100 lump of not really wriggling eldritch matter" )[/color]

Returned: [color=green]Hagnk's doesn't have that many of your lumps of not really wriggling eldritch matter, he's only got 3.[/color]

[color=green]> ash slash_command( "equip", "pants Pantsgiving" )[/color]

Returned: [color=green]Equipping Pantsgiving.[/color]

[color=green]> ash entity_encode( slash_command( "equip", "pants Pantsgiving" ) )[/color]

Returned: <font color=green>Equipping Pantsgiving.<!--js(dojax('inv_equip.php?action=equip&whichitem=6860&ajax=1&pwd=xxxx');)--></font><br>
1) I separated out the command and parameters so that we can filter based on command, if we wish. For example, we don't want to allow scripts to spam people, so we could disallow "msg", say. I'm not sure if we disallow that in the CLI.

2) The function returns the raw response, complete with HTML formatting. That's why all those responses are green: they are wrapped in "font" tags which make them green.

3) Notice how the "/equip" command works: it sends back a green message saying "Equipping ITEM", but also a javascript comment to actually do the equip. Both the browser chat client and KoLmafia chat (including "/" commands in the gCLI) dutifully submit the URL. This command does not; it returns to the script exactly what it got from KoL, so when I submitted an "equip" command, it didn't really change my equipment.

4) Notice how using "pull" (or "closet or "uncloset") can be learned to discover plurals.

Should I submit this? Are there any commands we should disallow?
 
Last edited:

lostcalpolydude

Developer
Staff member
1) I separated out the command and parameters so that we can filter based on command, if we wish. For example, we don't want to allow scripts to spam people, so we could disallow "msg", say. I'm not sure if we disallow that in the CLI.

Using / in the CLI sends whatever you tell it to. If a disallowed action is detected (messaging a public channel I guess?) then no more chat commands can be sent of any type. At least that's what I remember. The code was confusing when I tried following it a while back.
 

Veracity

Developer
Staff member
I see this code in ChatSender.executeMacro:

Code:
			ChatSender.scriptedMessagesEnabled =
				recipient == null ||
				recipient.equals( "" ) ||
				recipient.equals( "/clan" ) ||
				recipient.equals( "/hobopolis" ) ||
				recipient.equals( "/slimetube" ) ||
				recipient.equals( "/dread" ) ||
				recipient.equals( "/hauntedhouse" );
which does what you describe.

I'm using the same mechanism as is_online() uses - the InternalChatRequest.

I think I need to filter out anything which will actually result in something appearing on a chat channel. Just a Simple Matter of Coding, I imagine. ;)
 

Veracity

Developer
Staff member
It would be simpler to just have a set of allowed commands.
It would be even simpler to just have slash_count().
Which is what I will do.
 
Top