urls & relays & make_url(), oh my!

StDoodle

Minion
I'm stumped; I have two scripts, one a "regular" script and one a relay script, for sending kmails / gifts (with functions borrowed and trimmed from zlib, natch).

The regular script operates perfectly, and sends things to people as expected.

The relay script, however, seems to bork the form submission url, resulting in a KoL response that includes "Incorrect form submission."

However, debugging using make_url() results in identical test strings; I have no idea why this works in one script and not the other.

Any help would be greatly appreciated!
 

Attachments

  • giftZlibTest.ash
    3.1 KB · Views: 38
  • relay_Gift_Bot.ash
    15.9 KB · Views: 41

Catch-22

Active member
A potential problem I can see from just looking at the script would be that you are telling KoLmafia that the visit_url string is already encoded but you're not ensuring every parameter is, in fact, encoded. I would suggest you either url_encode every input, or you encode none of them and let KoLmafia handle it.

Having said that, there is possibly more going on that is not entirely obvious when your query string is being converted to POST.

Unfortunately, I don't have a lot of time to play at the moment. I suggest you turn debugging on and verbosely log HTTP communication, then compare the logged HTTP requests of the two scripts.
 

StDoodle

Minion
Hmm... how does one verbosely log HTTP communication?

Edit to add: they started out as the 1-parameter version, and I played around with them... that's just the latest incarnation.
 

Catch-22

Active member
Hmm... how does one verbosely log HTTP communication?

Sorry, the correct terminology is "verbosely log communication between KoLmafia and browser", it's a bit of a mouthful. It can be found in the Options frame under "Extra Debugging".

I should write a wiki entry on it, it has come up a few times :)
 

StDoodle

Minion
Ok, got it working. For later, when I have time to put this up and save myself some headache on the next round :)D), here's what needs to be known:

1) You need to use the 3-parameter version in a relay script if you might possibly maybe use any ampersands in any way. I'm sure there are exceptions, but hey... better safe than sorry unless someone wants to go down the full list for me. ;)

2) Be very careful with url_encode(); use it on every string that might need it (including player names): DON'T use it on stuff that's already in the correct format

3) Here's what I keep forgetting: you need to use 'pwd="+my_hash()' somewhere in your url string in the 3-parameter visit_url().

Sorry for being a bother (again)! :)
 

Attachments

  • relay_Gift_Bot.ash
    15.5 KB · Views: 44

Catch-22

Active member
Sorry for being a bother (again)! :)

Hey it's not a bother. Now that you know how to debug scripts a little better, not only do you know what to do for next time, but you can impart this wisdom upon others in a similar situation.

Good job on mostly figuring it out for yourself ;)
 

StDoodle

Minion
Yeah, but this is a slippery-slope. I've been more of a "documentation" guy forever, and some scripting, despite how long I've been hangin' around here. Now you've got me analyzing debug logs, what's next? Combing through the source? Blasphemy! :p

Thanks for the help, that verbose setting is very good to know about.
 
Top