Newbie Notify Help

InfernalRapture

New member
I have a CLI script.

I also have a relay script which basically calls all the same functions but writes it into the relay browser.

I want to be notified exactly once, no matter which flavor is run.

Putting notify at the top of the CLI script causes it to report that the CLI script was run, but will not tell me anything if the relay script was used.

It seems as though the notify command uses File Paths to identify the script, so putting it at the top of both files will tell me once for each side, causing double reporting for those users who go both ways.

Is there a way to make it do what I want? If not, I can roll my own if someone will please show me how I can send a kmail from ASH, that has no meat or items attached.

One last note, I don't want to import some external library to do this. That would force a dependency I don't want to inflict on my users. If you point me at one, I might steal code, but I won't be using your library. I'd much rather you save me the trouble and post a code-snippet.
 

StDoodle

Minion
Not really doable without a massive build-your-own solution, as-is. However, you could make the relay script import the cli version. Disadvantage; introduces a single (but put-in-one-threadable) dependency for the relay users. Advantages; simply put the notify in the imported script, and it will only fire once*. Also, less worry about keeping two codebases updated.

* Well, not entirely true; certain things can result in a re-done notification kmail, such as completely reinstalling KoLmafia; it isn't "hard-coded" to the actual KoL account in some way.
 

StDoodle

Minion
Oh, I see. I coulda sworn I'd done something similar once and it only triggered a single notification, but I could be misremembering. Or perhaps something changed...

Ok, did a bit more digging, looks like notifications are stored in your "GLOBAL_prefs" file as "previousNotifyList." I imagine it might be possible to parse that to see if a notification has already been made for a given script, but that would still involve rolling your own notification. I think I'd lean more toward a Feature Request that allowed one to set up a once-only notification, or perhaps just a change to the default behavior. (As a script author, I can't see any need for a new notification when a user moves a script of mine from one directory to another, for example.)
 

Theraze

Active member
But if you have a script named fight.ash and a relay script that overrides fight.php, then they'd both be called fight.ash and your only way to differentiate them is by directory...
 

roippi

Developer
You could just avoid using notify entirely, use something like

Code:
if ( to_int( get_property("infernalVersion") ) < VERSION_CONSTANT )
{
set_property( "infernalVersion", VERSION_CONSTANT);
cli_execute( "csend " + message );
}

Note hasty untested code, you should do more sanity checking on get_property, etc. Using zlib would provide some improved functionality, though I know you don't want that.

edit: just remembered that csend has to send an item. You can tell how often I do ASH scripting nowadays. Um.. yeah, I'd normally just use a zlib function, you can probably adapt that function if you don't want to introduce a dependency.
 
Last edited:

jasonharper

Developer
Put identical 'script' directives at the top of both files, and they should be considered identical for notification purposes:

script "My Script";
notify "Me";
 

StDoodle

Minion
Just tested myself, and while the imported script does not trigger a notify during import, running both separately will result in two kmails. Ideally, using the "script" directive would force a once-per-script behavior, methinks. At least, that's my $0.02.
 

fronobulax

Developer
Staff member
Ideally, using the "script" directive would force a once-per-script behavior, methinks. At least, that's my $0.02.

That's a FR right? I was looking at the code and the parameter of interest is the file name associated with the Interpreter. Interaction with "script" was not obvious to me.
 

StDoodle

Minion
Indeed, that looks like what this should be. I'm just pointing out that since multiple people seem to have thought that was how it worked in the first place, it seems as if it would likely be considered a reasonable one.
 

jasonharper

Developer
Changing the behavior at this point would result in resent notifications for every single script in existence that uses the 'script' directive.
 

Bale

Minion
As someone who gets a lot of notifications I don't think that is a big problem. Right now I frequently get multiple notifications from a single person. This happens because they run the script through dropbox on another PC, so the path is different. Or they have it on a USB drive, so the path is frequently different. Or they move their mafia directory, so the path is different, Or they reorganize their /scripts diretory to use subdirectories, so the path is different.

While a change in the behavior would result in resent notifications for every single script, in the long run it will definitely cut down on the number of notifications that I receive from many users.
 

Theraze

Active member
Interesting, on my system, it looks like this was a change in the past few years, since I have
previousNotifyList=<><scripts\\dailydungeon.ash><scripts\\miner.ash><scripts\\trafa.ash><scripts\\dwarven_factory.ash><scripts\\Wossname.ash><scripts\\canadv.ash><scripts\\autoclub.ash><scripts\\hccheck.ash><C\:\\Program Files (x86)\\KoLMafia\\scripts\\Universal_recovery.ash>
List goes on quite a ways, but... up until I started using UR, it looks like it was just saving the relative location rather than specific location. Maybe it's an EXE v. JAR thing, or stable v. daily, or something similar... Might even just be unnamed v. named, with unnamed working rationally, since canadv never defines script (just does a notify) and it only shows up once, unlike UR which shows up 3 times...
 

lostcalpolydude

Developer
Staff member
As someone who gets a lot of notifications I don't think that is a big problem. Right now I frequently get multiple notifications from a single person. This happens because they run the script through dropbox on another PC, so the path is different. Or they have it on a USB drive, so the path is frequently different. Or they move their mafia directory, so the path is different, Or they reorganize their /scripts diretory to use subdirectories, so the path is different.

Or I call it from the CLI (leaving off the .ash part of the name and using all lowercase), and then later I use the Scripts dropdown.
 

Theraze

Active member
Yeah... calling the script from the gCLI causes additional notifications from the same computer. Since I have 3 copies of eatdrink listed, including all lowercase with full path, propercase with just script, and wonkycase (eAtdrink) with full path.

It's possible that importing the script is what causes the propercase form, since my aliases all import EatDrink.ash, and that only shows up with the scripts\EatDrink.ash form.
 

Bale

Minion
Yeah, I have also seen scripts send new notifications because I typed their name on the command line.

In short, the current notify system is not ideal. This seems worth having all notifications resent in order to make it stop sending many new notifications for minor changes.
 
Top