-- Rotating Message 1.0b -- by Mutor The Ugly -- -- Rotates 5 text files posted to main chat at interval -- Option to start script in on or off mode -- Option to start or stop script manually -- -- --User Settings--------------------------------------------------------------------- bot = "[AdBot]" -- Name for bot delay = "30" -- Interval, in minutes between each message file1 = "txt/file1.txt" -- First file to post, should reside in 'scripts\txt' folder file2 = "txt/file2.txt" -- Second file to post, should reside in 'scripts\txt' folder file3 = "txt/file3.txt" -- Third file to post, should reside in 'scripts\txt' folder file2 = "txt/file4.txt" -- Fourth file to post, should reside in 'scripts\txt' folder file3 = "txt/file5.txt" -- Fifth file to post, should reside in 'scripts\txt' folder Prefix = "+" -- Command Prefix RunComm = "adon" -- Command to start ads StopComm = "adoff" -- Command to stop ads RunStatus = "1" -- Start script on or off -> 1=on 0=off --End User Settings----------------------------------------------------------------- counter = "0" function Main() SetTimer(delay*60000) StartTimer() end function OnTimer() if RunStatus == "1" then Messages() end end function DataArrival(user, data) s,e,cmd = strfind(data, "%b<>%s+(%S+)(%S+)") if user.bOperator then if (cmd==Prefix..RunComm) then RunStatus = "1" user:SendData (bot,"Messages started...") OnTimer() return 1 elseif (cmd==Prefix..StopComm) then RunStatus = "0" user:SendData (bot,"Messages stopped...") return 1 end end end function Messages() if counter == "0" then filename = file1 local sdata = DoFile(filename) SendToAll(bot,"\r\n\r\n"..sdata) counter = "1" elseif counter == "1" then filename = file2 local sdata = DoFile(filename) SendToAll(bot,"\r\n\r\n"..sdata) counter = "2" elseif counter == "2" then filename = file3 local sdata = DoFile(filename) SendToAll(bot,"\r\n\r\n"..sdata) counter = "3" elseif counter == "3" then filename = file4 local sdata = DoFile(filename) SendToAll(bot,"\r\n\r\n"..sdata) counter = "4" elseif counter == "4" then filename = file5 local sdata = DoFile(filename) SendToAll(bot,"\r\n\r\n"..sdata) counter = "0" end end function DoFile(filename) local handle = openfile(filename,"r") local sdata = "" if handle then sdata = read(handle,"*a")-- sdata = gsub(sdata,"|",strchar(166)) sdata = gsub(sdata,"\n","\r\n") closefile(handle) end return sdata end