| Message |
Well, the exact solution would depend on the scripting language - you mentioned Perl - and the format of the who list.
However the general idea would be to make a trigger that matches what the who list output looks like, eg.
Player Name On For Idle M*U*S*H, better than sliced Bread! ^-^
Valetrem 00:02 1m I am sleeping
Ererran 00:08 7m
Fire 00:17 17m Building
Jeriraron 00:18 2m
Galasean 00:18 6m Cataloguing stars
Edag 00:19 19m
Gwa 00:39 18m
Gwiratrem 01:04 1h
Chemas 3d 20:22 16h Erm, uh, something?
There are 9 players connected.
Probably best to match this sort of stuff with a regular expression, see http://www.gammon.com.au/mushclient/regexp.htm for details about doing that.
In this case you want 3 triggers, one to start the list, one to capture each item, and one to finish the list and work out duplicates etc.
The "start" trigger might be:
Match: ^Player Name\s+On For\s+Idle\s+.*^
The "\s+" entries means "one or more spaces".
This trigger could empty out the player list variable, and enable trigger 2.
eg..
Send to: script
Send: world.SetVariable "newlist", ""
world.EnableTrigger "whomatch", 1
Regular expression: checked
Trigger 2, the "who item" trigger might be:
Match: ^(.*?)\s(\d+ d)?\d+\:\d+\s+\d+(h|m|s)\s+.*$
Label: whomatch
This matches the name, time on, and idle time, plus an optional comment.
This trigger could add to a variable, like this:
Send to: script
Send: world.SetVariable "newlist", world.GetVariable ("newlist") & "," & "%1"
Regular expression: checked
Finally, trigger 3 detects the end of the list:
Match: ^There are \d+ players connected.$
Regular expression: checked
This one disables trigger 2, and then compare the new player list to an earlier one, looking for new ones, and takes appropriate action, then it copies the new list to the old list, ready for next time.
In VBscript you might use "split" to split the list of names at a comma, and then "for each" to work your way through the list.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|