#--------------------------------------------------------------------- # lastseen.tcl # # Upon a public !last this script reports the last 10 handles seen # most recently. # # v0: 02-Jul-2003 # v1: 03-Jul-2003 # v2: 03-Jul-2003 # v3: 27-Oct-2003 # + omit bots #--------------------------------------------------------------------- package require Tcl 8.0 package require eggdrop 1.6.13 bind pub - !last pub:lastseen bind dcc - last dcc:lastseen #--------------------------------------------------------------------- # handle pub and dcc requests #--------------------------------------------------------------------- proc pub:lastseen { nick uhost hand chan text } { puthelp "PRIVMSG $chan :[all:lastseen]" return 1 } proc dcc:lastseen { hand idx text } { putdcc $idx "[all:lastseen]" return 1 } #--------------------------------------------------------------------- # iterate on the userlist and report the 10 most recently seen hands. #--------------------------------------------------------------------- proc all:lastseen { } { set lastonlist [list] # iterate on list foreach user [userlist] { # skip handles currently online if { [hand2nick $user] != "" } { continue } # skip bots (flag b) if { [matchattr $user b] } { continue } # retrieve laston time set laston [getuser $user LASTON] set laston [lindex $laston 0] if { $laston == 0 } { continue } if { $laston == "" } { continue } lappend lastonlist [list $laston $user] } # any handles found? if { [llength $lastonlist] == 0 } { set msg "Didn't see anybody recently." return $msg } # sort the list, take first 10 handles, # compute when seen and report. set lastonlist [lsort -index 0 -integer -decreasing $lastonlist] set lastonlist [lrange $lastonlist 0 9] set currenttime [clock seconds] set msg "Last seen:" foreach { lastonuser } $lastonlist { set laston [lindex $lastonuser 0] set user [lindex $lastonuser 1] set laston [ expr $currenttime - $laston ] set laston [duration $laston] # only most significant part e.g. "2 days" or "5 minutes". set laston [split $laston] set laston [lrange $laston 0 1] set laston [join $laston] append msg " \002$user\002 ($laston ago)" } append msg "." return $msg } putlog "Loaded (version 3): Lastseen."