@name Cleverbot Interface
@persist State Log:array [URL Session]:string Last

interval(1000)
runOnChat(1)
runOnHTTP(1)

if(first()) {
    URL="http://scriptisnet.byethost7.com/Chatter/Chatter.php?s=1e17qbbc"
    Session="?s=1e17qbbc"
    function number send(S:string) {
        local Link=URL+"?s="+Session+"&m="+httpUrlEncode(S)
        printColor(vec(255,255,0),"CB",vec(0,255,0)," -> ",vec(255),S)
        httpRequest(Link)
        return 1
    }
}



if(chatClk() & lastSaid():sub(1,2)=="!c") {
    if(curtime()>Last & httpCanRequest()) {
        local Msg=lastSaid():sub(4)
        send(Msg)
        Last=curtime()+3
    } elseif (curtime()<Last) {
        concmd("ulx tsay \"CB: You must wait at least "+round(Last-curtime())+" more seconds.\"")
    } elseif (!httpCanRequest()) {
        concmd("ulx tsay \"CB: Request could not be sent.\"")
    }
}

if(httpClk()) {
    printColor(vec(255,255,0),"CB: ",vec(255),httpData())
    concmd("ulx tsay \"CB: Cleverbot > "+httpData()+"\"")
}
