--By Dessamator
--"Box Msg" aka status bar sender v1.2
--Idea from Chatterbot
--request by dkt
tLines = {n=0}
--Config
bot=frmHub:GetHubBotName() --bots name
Filename = "boxmsgs.txt" -- enter filename
Time = 10 -- enter time in minutes
TimerOn =false -- true to send box msg at intervals
--
function Main()
local file=io.open(Filename,"r")
if not(file) then
io.output(Filename)
io.close()
io.output()
end
if TimerOn then
SetTimer(60000*Time)
StartTimer()
end
end
function ChatArrival(user,data)
data= string.sub(data,1,string.len(data)-1)
s,e,cmd,msg = string.find(data,"%b<>%s+(%S+)%s+(.*)")
if msg then
if cmd =="!sendmsg" and string.len(msg)<120 then
SendToAll("\t"..msg..string.rep("\t",11).." is kicking because:")
return 1
elseif cmd == "!addboxmsg" then
addline(Filename, msg)
user:SendData(bot,"Done ,added box msg!")
return 1
elseif string.len(msg)>120 then
user:SendData(bot,"Message too long !")
return 1
end
end
end
function OnTimer()
GetLines(Filename)
for pos,line in tLines do
if tonumber(pos) and line and i then
if tonumber(pos)<=i then
temp=line
end
elseif not(i) or i==table.getn(tLines) then
i=1
end
end
if temp then
i=i+1
SendToAll("\t"..temp..string.rep("\t",11).." is kicking because:")
end
end
function GetLines(filename)
tLines =nil
tLines = {n=0}
local file = io.open(filename, "r")
for line in file:lines() do
table.insert(tLines, line)
end
file:close()
end
function addline(filename,msg)
local file = io.open(filename, "a+")
file:write("\n"..msg)
file:close()
end