Player Purge

From Gwen Morse's Wiki
Jump to: navigation, search
;;; Gwen: Note -- completely untested!
;;; Player purges
;;; From: (Javelin's Guide for PennMUSH)
;;; After a while, you may want to remove old players and their objects 
;;; from your game. I typically use tinyfugue macros, rather than MUSHcode 
;;; to do this. First, I define a macro /nuke <player>, which nukes a player 
;;; and everything they own, providing they're not currently connected: 

/def nuke = @switch hasflag(pmatch(%1),connected)=1,{think %1 is connected!}, {@dol lsearch(%1,none,none)=@nuke ##} 

;;; The connected check prevents you from accidentally nuking yourself.

;;; Then, I define a player purge macro like this: 

/def ppurge = @dol lsearch(all,type,player)=@switch [and(not(orflags(##,Wr)),lt(convtime(xget(##,last)),sub(convtime(time()),2419200)))]=1, {think /nuke [name(##)] ## [lstats(##)]}

;;; This macro searches the db for all players and lists those who aren't admin 
;;; and whose last connection was longer than 28 days ago.

;;; Actually doing a purge, then, requires these steps: 

;;; 1./log purge, to start logging output to a file called 'purge' 
;;; 2./ppurge, to list players who are candidates for purging 
;;; 3./log off, to stop logging 
;;; 4./sh vi purge, to edit the purge file and see who'll be purged. 
;;;   Delete lines in the file for players who you don't want to see purged. 
;;;   What's left will be a list of /nuke lines which will purge the players you want purged. 
;;; 5./quote 'purge, to load the commands in the purge file and do the actual purging. 
;;; 6./sh rm purge, to remove the purge file.
;;; [ Rhyanna notes that the tinyfugue purge macros which I discuss are incomplete. 
;;; /nuke may leave rooms with more than 3 exits, and the lsearch() may fail to get all
;;; the players due to buffer length problems. - Javelin ]