#--------------------------------------------------------------------- # chanxs.tcl # # Tcl script for IRC bot eggdrop. # Usage: !chanxs # Displays the access levels to the channel of all users in the # userlist. # # v0: 25-Oct-2002 # v1: 22-Dec-2002 #--------------------------------------------------------------------- package require eggdrop 1.6 package require Tcl 8.0 bind PUB m|m !chanxs showchanusers proc showchanusers { nick uhost hand chan text } { # the flaglist in order of importance! # the flagmatching uses eggdrops matching system, e.g. o|o # denotes a uses having global or channel operator flag. set flaglist {n|n m|m o|o f|f v|v} # flagnames are used when outputting the results. set flagname(n|n) owner set flagname(m|m) master set flagname(o|o) operator set flagname(f|f) friend set flagname(v|v) voice # review all users in the userlist foreach user [userlist] { foreach flag $flaglist { # check if user has global or channel access. if {[matchattr $user $flag $chan]} { # check if the user is on the channel set usernick [hand2nick $user $chan] if { $usernick != "" && $usernick != $user } { set user "$user (aka $usernick)" } lappend userswithflag($flag) $user break } } } # any results? if { ![array exists userswithflag] } { puthelp "PRIVMSG $chan :\002userlist\002: no results." return 1 } # output header set line "([ctime [unixtime]]) userlist results for $chan:" puthelp "PRIVMSG $chan :\002$line\002" # output all results. foreach flag $flaglist { if {![info exists userswithflag($flag)]} { continue } # a flagname was set? if { ![info exists flagname($flag)] } { set flagname($flag) "Flag $flag" } # join the list to a string set list $userswithflag($flag) set list [lsort -ascii -increasing $list] set line [join $list ", "] # limit the string length. if {[string length $line] > 300 } { set line "[string range $line 0 300] ..." } puthelp "PRIVMSG $chan :\002$flagname($flag)\002: $line" } # output footer. set line "End of userlist results for $chan." puthelp "PRIVMSG $chan :\002$line\002" # log the request. return 1 } putlog "Loaded (version 1): Chanxs."