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

zarqon

Well-known member
[size=+1]Script Registry 1.9[/size]
For script authors

As a script author, I enjoy using the "notify" command at the top of my scripts. Then when someone uses my script, I get a kmail letting me know that someone liked my script enough to use it. The cockles of my heart are warmed. But, what to do with all these notification kmails? Surely they can serve some purpose besides just cockle-warming...

And so, Script Registry was born.

What does it do?
In a nutshell, Script Registry allows you to keep a record of the information provided by the "notify" command. This record is kept on a remote server and is accessible from within the script or on a public web page (see below).

Every time you use the script, it parses your kmail and registers any appropriate information. After successfully registering the information, it deletes the kmails that it successfully parsed, then generates a report showing your current script use information.

The Script Registry Site
The information that is gathered by the use of this script is viewable on a public web site. It is my desire that this information be useful to the scripting community. Authors can track the use of their script, check to see if a certain script already exists, and find scripts that are useful to other players. Script users can find scripts that are useful to other players, or experienced authors from whom to request scripting assistance. It is currently hosted here:

Script Registry Online

Details
The "notify" command has long been available in mafia. If you write "notify <playername>;" at the top of your script (before any other commands), you will receive automated kmails from other mafia users when they use your script for the first time. It will say "I have opted to let you know that I have chosen to run <scriptname.ash>. Thanks for writing this script!"

Registry will recognize those kmails and (if you have already registered a script by that name) record who used your script, and when. It then deletes the kmail.

I must emphasize that this script is only useful for script authors who use the "notify" command at the top of their scripts. Even then, your information will not be recorded unless you first register your script using a simple command.

Registry Commands
You can instruct Registry.ash to do certain things by sending yourself a kmail containing certain commands. Registry.ash will follow these commands when it parses your kmail.

  • [register scriptname] - This is the most important command. Registry will not record anything for scripts unless they have been registered. Example: [register myscript.ash]
  • [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]
  • [url for scriptname is url] - You can use this command to register a URL for your script. Ideally, that would be the URL where the script can be downloaded (most likely here). Visitors to the Registry website will be able to follow that URL to download your script. Example: [url for myscript.ash is http://kolmafia.us/showthread.php?t=1234]

You can have as many of these commands as you like in a single kmail, in any order, but each command does need its own set of square braces.

How to use it:
  • Make sure your published script(s) correctly use the "notify" command.
  • Download Registry.ash.
  • Make sure you also have ZLib.
  • Register your script(s) using the [register scriptname] command (see above).
  • Regularly run this script to record and delete your notification kmails. I recommend adding it to your login script.

Changelog
3.31.08 - ver. 1.0 posted.
4.22.09 - 1.1 changes: fixed URL for version checking due to new forum software. Don't bork on filenames not including "scripts" now that the notify command does not include path info.
6.26.09 - 1.2 changes: integrated ZLib and made the available optimizations -- now uses improved version-checking and has cleaner string-parsing sections.
8.07.09 - 1.3 changes: fix a possible index-out-of-bounds error that could occur when notification kmails were forwarded.
12.30.09 - 1.4 changes: fixes dealing with mafia's changed handling of ints and strings. Use ZLib's new vprint().
5.01.11 - 1.5 changes: use ZLib's new load_kmail() for great justice. Only parse registry commands from yourself.
5.02.11 - 1.6 changes: using the api.php method of accessing kmail, links in message text are not clicky. Account for that when registering URLs.
6.15.11 - 1.7 changes: now uses ZLib's lovely process_kmail() for another drastic reduction in size! Further, using my regex tongs in a controlled environment I reworked the parsing to use matchers (*shudder*), so you can now include any number of commands in your kmail, and they will all be parsed in the correct order (unregisters, then registers, then urls).
10.24.12 - 1.8 changes: need 'www' in the url after nameserver change.
10.18.17 - 1.9 changes: 'http' -> 'https'
 

Attachments

  • Registry.ash
    3.2 KB · Views: 108
Last edited:

Paragon

Member
Re: Script Registry 1.0 -- for script authors; track your script usage

Nice script. Now I just wish I had remembered to put notifiy on my earlier scripts!

This won't count multiple notifies from the same user right?
 

zarqon

Well-known member
Re: Script Registry 1.0 -- for script authors; track your script usage

In the event of multiple notifies from the same user, it simply reports that that user has already been registered. This still counts as a successful parse, so it will delete that notification kmail.
 

Paragon

Member
Re: Script Registry 1.0 -- for script authors; track your script usage

I don't know if this would be a pain in the butt or not, but do you think it would be possible to make it so that we could do either of the following things:
1) Send a kmail to ourselves with some sort of tag (like the ones already implemented) that would let us add text at the top, under our name. Such as, I collect balls, and I know that a few other script writers around here collect particular items, I would like to be able to add a line or two about how if anyone felt like donating things to us here is a list of items we collect or what-have-you. And 2nd maybe be able to send a bit of text to attach it's self to the script it's self... such as current ver. number, updates, documentation etc. It wouldn't really have to be anything too intricate, just one set of plain text the scripter could use to write whatever information they felt was important.

And BTW, i really like the site and idea.
 

zarqon

Well-known member
Re: Script Registry 1.0 -- for script authors; track your script usage

Interesting ideas, Para...

1) That's possible to include a short bit of author information, like a tagline or what have you to personalize things a bit. I'll take a look at adding that soon.

2) If you want to include version information or documentation, do it a) in your script, or b) here! That's why you have the option of providing a link, so anyone interested can check here to make sure they have the latest version, or to figure out how to use it. Registry does not attempt (or want) to be a replacement site to this one.

(For anything other than really simple scripts, I recommend that all scripts include version info in the script. You could also include version checking by using visit_url() in the script to check your script's thread for version info, then alerting your users if there is an update. See the original idea, or see any of my scripts for a simplified adaptation of that idea.)

Thanks for the feedback!
 

zarqon

Well-known member
1.1 Updates!

A handfulk of script authors seem to be finding this useful, so I'm posting about this update since the version checking (broken since the forum change) wouldn't tell you.

Perhaps a week or two back, the notify command was altered so as not to include path info in the sent kmails. This resulted in a lot of notifications not being parsed correctly. This annoyance has gone on long enough. I finally fixed it today, so those of you who enjoy this functionality can have it back once more.

While I was at it, I fixed the version checking so further update posts such as this one should be unneccessary.
 

Bale

Minion
This is kinda cool... I think I might try out the notify command again now that I've noticed it (since notify now works properly).
 

Bale

Minion
I was wrong about it being kinda cool. Actually it's extremely cool. It's fun seeing my list of registered users increase when someone's mafia sends me mail.

Mafia will only send a message the first time someone runs the script and I used notify on my script once before so those people aren't sending me new messages, but fortunately I'd saved those mails in a text file in case I was ever curious about them. It wasn't too hard to modify your script to read in the old messages using file_to_map so I was able to get those old registrations into your database. ;)

Fun and informative. Turns the annoyance of notify messages into a pleasure.
 

bumcheekcity

Active member
Yo zarqon. I'm trying to use this, but the script just keeps printing:

<html><body>This script is only accessible from <a href="http://kolmafia.sourceforge.net/">KoLmafia</a>.</body></html>

But I AM using it from KolMafia...?
 

Bale

Minion
Maybe you ought to explain how you are trying to use it. Give details 'cause I can't wait to hear!
 

Bale

Minion
Please define "like any other script". Give us juicy details!

Though if you cannot figure out how to use it, I can only wonder at why you'd need to use it.
 

zarqon

Well-known member
@bumcheekcity: which version of mafia are you using? Did you edit the script at all?

Off the top of my head, I seem to recall that you will only get that error if you visit the registry URL without providing the necessary variables. (Which would happen if you just visit that URL in a browser, or if you hacked the script -- incorrectly.)
 

bumcheekcity

Active member
13.3.1, and I'm fairly sure I didn't edit the script. I might have looked at it an inadvertently modified it, I suppose, but I'm sure I wouldn't have saved it. I'll re-download today and test when I'm back from work.
 

bumcheekcity

Active member
2 messages queued.
Message 1: Registering bumcheekcity for 'hccheck.ash'...
<html><body>This script is only accessible from <a href="http://kolmafia.sourceforge.net/">KoLmafia</a>.</body></html>
[register hccheck.ash]
Message 2: Registering 'hccheck.ash'...
<html><body>This script is only accessible from <a href="http://kolmafia.sourceforge.net/">KoLmafia</a>.</body></html>
0 messages processed successfully.
Printing report...

That's what I get. I've just downloaded it and clicked "Scripts -> Register.ash"
 

mredge73

Member
hey
I registered a few scripts the other day

For some reason the link to them on the website does not work.

I just get:
There ain't no script named 'MrEdge73\\\'s HC Daily Inventory Control! (Beta) .ash' registered to mredge73.

I wonder if the apostrophe screwed it up?
 

zarqon

Well-known 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.

@mredge: Yep, looks like the apostrophe was escaped when being saved. It was then escaped again when passed to details.php for a closer look at your script. The data file has your script as:

MrEdge73\'s HC Daily Inventory Control! (Beta) .ash

(Yes, including the space at the end... you have two scripts like that... is that intentional?)

Apparantly all the mafia/PHP interactions are still functional with the backslash included, however -- you have registered users. Interesting.

I recommend against using punctuation in filenames, as a general principle. I would also advise not to include version info ("Beta") in the filename, as you will need to reregister once you have a final release.

I tried just removing the slashes from your scripts in the data file but that led to errors which I wasn't up to debugging at the moment. I also added stripslashes() to most of the Registry's incoming page variables, so your script links are at least working now. Also, future scripts registered should avoid this problem... I think. Let me know if anything else still doesn't work.
 

mredge73

Member
note to self, rename my script files better to work with registry.
thanks for your help.
 
Last edited:

mredge73

Member
I understand that I make annoying long names, I am not very creative.
I have probably changed my script names over a dozen times and I still don't like how they look or sound and when I make them short they disappear in my huge script folder.

note to self, short and sweet script file names
oh and they need to be catchy, creative, and provide information
sad thing here is that it will take me longer to rename them than it took to write them.
 
Top