All pastes #579649 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-20 19:39 UTC
rendered paste body
##############################################################################################
## Display All Sites

if { $disable(SELECTALL) == 0 } {
    bind pub -|- [set cmdpre]s sites

    proc sites { nick host handle channel arg } {
        global db cmdpre vers outprefix disable

        if { [llength $arg] == 0 } {
            set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
            set sql "SELECT shortname FROM $db(TABLE) WHERE channel='$channel'"
            if { $disable(DEBUG) == 0 } {
                putlog "$vers: Executing $sql"
            }
	    set result [mysqlsel $db_handle $sql -flatlist]
            if { $result == "" } {
                putserv "PRIVMSG $channel :$outprefix Available Sites (0) :: No Sites Found!"
                mysqlclose $db_handle
                return 0
            }
            putserv "PRIVMSG $channel :$outprefix Available Sites ([llength $result]) ::[join $result]"
            mysqlclose $db_handle
        } else {
            putserv "PRIVMSG $channel :Usage: [set cmdpre]s"
            return 0
        }
    }
}


##############################################################################################
## Search