internalbind command sbnc_bncuserlist
proc sbnc_bncuserlist {client params} {
    set params [split $params]
        
    if {[getbncuser $client admin] && [string tolower [lindex $params 0]] == "bncuserlist"} {
        set admins [list]
        set other [list]
        set sus_other [list]
        set online 0
        array set networks {}
        
        set ctx [getctx]
        
        foreach ident [bncuserlist] {
            setctx $ident
            
            if {[getbncuser $ident hasclient]} {
                incr online
                
                if {[getbncuser $ident admin]} {
                    set stats "@* "
                } elseif {[getbncuser $ident lock]} {
                    set stats " *!"
                } else {
                    set stats " * "
                }
            } elseif {[getbncuser $ident admin]} {
                if {[getbncuser $ident lock]} {
                    set stats "@ !"
                } else {
                    set stats "@  "
                }
            } elseif {[getbncuser $ident lock]} {
                set stats "  !"
            } else {
                set stats "   "
            }

            set server [getbncuser $ident server]
            set vhost [getbncuser $ident vhost]
            set seen [getbncuser $ident seen]
            
            if {$vhost == ""} {
                set vhost "default vHost"
            }
            
            if {$seen == 0} {
                set seen "Never"
            } elseif {[getbncuser $ident hasclient] == 1} {
                set seen "Online from [getbncuser $ident client]"
            } else {
                set seen [duration [expr {[unixtime] - [getbncuser $ident seen]}]]
            }
            
            if {$server == ""} {
                lappend other [format "% 3s % -20s (%s) - %s" $stats $::botnick $ident $seen]
            } else {
                set server "$server via $vhost"
                if {![info exists networks($server)]} {
                    set networks($server) [list [format "% 3s % -20s (%s) - %s" $stats $::botnick $ident $seen]]
                } else {
                    lappend networks($server) [format "% 3s % -20s (%s) - %s" $stats $::botnick $ident $seen]
                }
            }
        }
        
        setctx $ctx
        
        bncreply "Bouncer-Userlist ($online/[llength [bncuserlist]] online):"
        foreach name [lsort -dictionary [array names networks]] {
            bncreply "[llength $networks($name)] User(s) on $name:"
            foreach x $networks($name) {
                bncreply $x
            }
            bncreply "---"
        }
        if {[llength $other] > 0} {
            bncreply "[llength $other] User(s) with no server set:"
            foreach x $other {
                bncreply $x
            }
            bncreply "---"
        }
        bncreply "End of List"
        haltoutput
        return
    }
}
