Script Registry -- for script authors; track your script usage

bumcheekcity

Active member
@bumcheek: Looked at the PHP... it's still checking to see that the agent is identified as mafia. I bet you've set mafia's "use last browser's userAgent" preference (on the "General" tab). Unchecking that preference and restarting mafia would probably allow you to run this script just fine, with little to no effect on your relay browser play.

I think that check is probably unnecessary (perhaps I was a little overzealous about security) and I'll look for a way to rewrite that. For now, I would recommend unchecking that setting.

That worked perfectly. Perhaps you should say that on the error, but not to sound ungrateful. Thanks, the script's great!
 

bumcheekcity

Active member
Zarqon, what do you do about people who re-name your scripts before they use them? It's pretty obvious they're users of the script, but they named it hccheck-cc.ash or whatever, so it won't work with the script.
 

Bale

Minion
I can tell you what I do when that happens. I add a line to register_user() that looks like this:

if(scriptname == "chamoix.ash") scriptname = "chamois.ash";

You should be able to figure out exactly where in the function to insert it. ;) Then I just change the specifics based on the kmail.
 

zarqon

Well-known member
I originally planned a kind of "aliasing" idea, where you could register aliases of scripts by typing [register secondaryscriptname alias of primaryscriptname]. This is supported in the ASH script, but is still not supported server-side.

For now, Bale's solution ought to do you nicely. Personally, I usually just delete those notifications. But it is becoming common knowledge that I am not as OCD as he is.
 

Bale

Minion
LoL! Yeah, I like certain things to be done precisely. If someone sends me a notification for one of my scripts I want it sorted properly even if they change the name.

Anyway, I'd say that anyone who has a valid need for this script should be able to figure out such a minor detail as how to use that information I provided in the previous post so it isn't important for you to update the script for such eventualities. This is a script for script writers after all.
 

mredge73

Member
hello Zarqon

I have a low priority request:

  • [unregister scriptname] - Use this command to delete a script you have registered from the registry. At present, scripts cannot be unregistered if they have more than one registered user. Example: [unregister myscript.ash]

Can this be updated so an author can remove scripts no longer supported?
Personally, I have changed the name of 3 of my scripts that I have registered and would like to be able to remove them since I no longer support them by that name.

Again, this is low-priority. They are not hurting anything by being up there, just making a mess.
 

Bale

Minion
What might be better and more useful is: [changename oldscriptname newscriptname]

which would merge the user lists of the two scripts into newscriptname while removing the entry for oldscriptname. I think that is really what you want. It would tidy up your list of scripts without losing any relevant information.
 

zarqon

Well-known member
If you want to change the name of a script, just kmail/PM me, and I'll edit the data file directly. Then all your previously registered users will persist. In your case, if you've already added the renamed scripts to the registry, that presents more of a difficulty. Let me know what you'd like to do.

PS -- yay for the recent "script" directive, eh? I should probably include this in the Wiki page I made for notify.
 

Bale

Minion
I just wanted to thank you again for this script. Whenever I have a heavy notify day...

14 messages processed successfully.
Deleting processed mail...
14 messages deleted.

That makes me so glad that I didn't have to check them all manually. It's nice when they disappear and I can find a few personal messages from their midst.

Thanks zarqon.
 

zarqon

Well-known member
Certainly!

But don't thank me too much -- I made it first for myself. :) If I'm away from my computer for a few days, or if mafia makes some change that appears to clear a lot of people's "used scripts" preference, I'm very glad for this script. I've had upwards of 50 notify messages get processed in one batch.
 

Bale

Minion
Oh well, I know I don't have anywhere's near as much need for this script as you do, but I had already decided that notify was more trouble than it was worth until I tried this. This script is the difference between notify being a blessing or bane.
 

bumcheekcity

Active member
Btw zarqon, I'm getting lots of "Unexpected error, debug log printed." messages when there are messages to be processed. I think it's due to trying to store things that aren't integers in the integer type:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
KoLmafia r7917, Windows XP, Java 1.6.0_17
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Please note: do not post these logs in the KoLmafia thread. If
you would like us to look at the log, please instead email logs
to veracity@hambo.com using the subject "KoLmafia Debug Log"
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Timestamp: Thu Dec 24 08:19:04 GMT 2009
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.NumberFormatException: sel94694817
java.lang.NumberFormatException: sel94694817
at net.sourceforge.kolmafia.utilities.StringUtilities.parseInt(StringUtilities.java:701)
at net.sourceforge.kolmafia.textui.DataTypes.parseIntValue(DataTypes.java:218)
at net.sourceforge.kolmafia.textui.RuntimeLibrary.to_int(RuntimeLibrary.java:1508)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:119)
at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:156)
at net.sourceforge.kolmafia.textui.parsetree.Assignment.execute(Assignment.java:89)
at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
at net.sourceforge.kolmafia.textui.parsetree.Conditional.execute(Conditional.java:88)
at net.sourceforge.kolmafia.textui.parsetree.If.execute(If.java:67)
at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
at net.sourceforge.kolmafia.textui.parsetree.Loop.execute(Loop.java:57)
at net.sourceforge.kolmafia.textui.parsetree.ForLoop.execute(ForLoop.java:183)
at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:127)
at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:156)
at net.sourceforge.kolmafia.textui.parsetree.Assignment.execute(Assignment.java:89)
at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
at net.sourceforge.kolmafia.textui.parsetree.Conditional.execute(Conditional.java:88)
at net.sourceforge.kolmafia.textui.parsetree.If.execute(If.java:67)
at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
at net.sourceforge.kolmafia.textui.parsetree.Switch.execute(Switch.java:138)
at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:234)
at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:191)
at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:184)
at net.sourceforge.kolmafia.textui.command.CallScriptCommand.call(CallScriptCommand.java:193)
at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:482)
at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:366)
at net.sourceforge.kolmafia.KoLmafia.login(KoLmafia.java:678)
at net.sourceforge.kolmafia.request.LoginRequest.processLoginRequest(LoginRequest.java:429)
at net.sourceforge.kolmafia.request.GenericRequest.handleServerRedirect(GenericRequest.java:1403)
at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1333)
at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1064)
at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:955)
at net.sourceforge.kolmafia.request.LoginRequest.run(LoginRequest.java:280)
at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:73)
at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.doLogin(LoginFrame.java:353)
at net.sourceforge.kolmafia.swingui.LoginFrame$LoginPanel.actionConfirmed(LoginFrame.java:300)
at net.java.dev.spellcast.utilities.ActionPanel$ConfirmedListener.run(ActionPanel.java:164)
at java.lang.Thread.run(Unknown Source)
 

Veracity

Developer
Staff member
Btw zarqon, I'm getting lots of "Unexpected error, debug log printed." messages when there are messages to be processed. I think it's due to trying to store things that aren't integers in the integer type:
That does look what it's doing. Unfortunately, the stack trace won't help him find out which line in his script is buggy. I'll look into trapping such errors in to_int() and giving a more helpful message, including file and line of code.

Edit: we used to do exactly that, but the new code in StringUtilities.parseInt pre-empted it and forced a stack trace to be printed. to_int() now calls a version which intentionally throws an exception if it can't parse, traps the errors, and gives a usual ASH runtime error.
 
Last edited:

mredge73

Member
Change line 106 from:
parsedmail[p].id = to_int(substring(km,0,index_of(km,"\"")));

to:
parsedmail[p].id = to_int(substring(km,3,index_of(km,"\"")));

This will fix the problem. Something must have changed for to_int().
 

Veracity

Developer
Staff member
Something must have changed for to_int().
Yes. This has been heavily discussed all over these forums. You can no longer pass in non-integers and get KoLmafia to, miraculously, give you an integer.

Used to be, as in this script, if you gave it "sel1234", it would return 1234. I suppose that might make a little bit of sense. But, you could also give it "1 for me and 2 for you" and get back 12.

Bottom line: if you give a non-integer to to_int(), it is now considered to be an error.
 

zarqon

Well-known member
Fixed this and the other problem: print(integer + "string") now evaluates the whole thing as an integer for some reason. Changing it to print(to_string(integer) + "string") fixes that, which I had in quite a few of my scripts.

I'm still a bit sad about the apparent regression in to_int()'s functionality, but I've had some time over the holidays so I was able to go through most of my scripts that stopped working and "fix" them. Sigh, I miss the old functionality though.
 

dj_d

Member
Neat! Good script. Make many short mail to one handy web post. Like much. Sad broke. Happy now; it works.

Ble to you too!
 
Top