-- ShoutStats 1.0c -- -- by Mutor The Ugly -- Requested By Bastya_Elvtars -- -- ShoutCAST Status Grabber -- Grabs the current stream info -- Return to user or send to all -- -- Bug fix by Mutor 10/8/04 -- Fixed double url... -- -- Added Timer function 10/24/04 -- requested vy Psycho_Chihuahua --User Settings------------------------------------------------------------------------------------- Bot = "[ShoutCastStats]" --Name for bot Command1 = "+sr" --Get status now Command2 = "+srall" --Toggle send to all on/off Mins = 60 --Zeitabstand zwischen den Meldungen in Minuten TimerOn = 1 --Timer An - Aus mit 1 oder 0 ghostin = "http://helvetia.ath.cx" --SHOUTcast D.N.A.S. Status Address gport = 8000 --Port to connect to gfile = "/index.html" --default file for web page Send2Main = "yes" --Send results to all users? 'yes/no' --End User Settings---------------------------------------------------------------------------------- -- function Main() frmHub:RegBot(Bot) SetTimer(Mins*60000) Timed = "" StartTimer() end function OnTimer() Timed = 1 GetNews() return 1 end function GetNews(user, data) ghost = ghostin ghost = gsub(ghost, "http://","") ghost = gsub(ghost, "HTTP://","") GETHTML = "GET "..gfile.." HTTP/1.1\r\nHost: "..ghost.."\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" local socket, err = connect(ghost, gport) if socket == nil then local dsp2 dsp2 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n" dsp2 = dsp2.."\t >Connect Status:\t **Failed! - Unable To Connect\r\n" dsp2 = dsp2.."\t >Failure Cause:\t Bad Address or Port Number\r\n" dsp2 = dsp2.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n" user:SendData(Bot,dsp2) return 1 end local code = "" if not err then socket:timeout(4) socket:send(GETHTML..strchar(13,10)) local line = "" while not err do line, err = socket:receive("*l") code = code..line x = gsub(code, "^(.+)%s*Current Stream Information","") x = gsub(x, "Average","Avg%.") x = gsub(x, "(%s+)Written","") x = gsub(x, "Current Song%s.+(<%/td>.+)","") x = gsub(x, "
(.+)Written","Written") x = gsub(x, "Written%s.+","") x = gsub(x, "(aim.+A\">)","") x = gsub(x, "(%S+","") x = gsub(x, " "," ") x = gsub(x, ""","\"") x = gsub(x, "»","»") x = gsub(x, "&","&") x = gsub(x, "<","<") x = gsub(x, ">",">") x = gsub(x, "%%20"," ") x = gsub(x, "%s%s+","") x = gsub(x, "™","™") x = gsub(x, "©","©") x = gsub(x, "®","®") x = gsub(x, "•","•") x = gsub(x, "°","°") x = gsub(x, "·","·") x = gsub(x, "","\r\n\t") x = gsub(x, "","\t - \t") x = gsub(x, "
","\r\n") x = gsub(x, "<([^>]-)>","") end socket:close() end socket:close() local dsp dsp = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=<>=-=\r\n" dsp = dsp.."\t\tSHOUTcast D.N.A.S. Status For: \t[ "..ghost..":"..gport.." ]\r\n" dsp = dsp.."\t\t\t**** Current Stream Information ****\r\n" dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=<>=-=\r\n" dsp = dsp..x if Timed == 1 then SendToAll(Bot,dsp.."\r\n") Timed = 0 return 1 end if Send2Main == "yes" then SendToAll(Bot,dsp.."\r\n") else user:SendData(Bot,dsp.."\r\n") end end function DataArrival(user, data) if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(Bot)) == "$To: "..Bot) then data = strsub(data,1,strlen(data)-1) s,e,cmd = strfind(data,"^%b<>%s+(%S+)")-- if (cmd == Command1) then GetNews(user, data) return 1 elseif (cmd == Command2) then if Send2Main == "no" then Send2Main = "yes" user:SendData(Bot,"Shoutcast status ' Send To All ' is now [ON]") elseif Send2Main == "yes" then Send2Main = "no" user:SendData(Bot,"Shoutcast status ' Send To All ' is now [OFF]") return 1 end end end end