Hello all
I need a script for a timed message in main
the reads the message from a .txt file
i want to set the time in minutes
so i set 120 minutes the message will appear after 2 hours and then again after 2 hours.
And i want to use it for some profiles not all so i that i can change that which profile the message can see and which profile not
And i want that it can read two .txt files which i can set seppared times:
txt file 1 = 120 minutes
txt file 2 = 210 minutes
if thats possible
Thx in advanced
Syphrone-NL
-- Rotating Message 1.1 by jiten
-- based on Rotating Message 1.0 by Mutor The Ugly
-- Rotates n text files posted to main chat at interval
--
--User Settings---------------------------------------------------------------------
mSet = {
sBot = frmHub:GetHubBotName(), -- Bot Name
RunStatus = 1, -- Auto Start -> 1=ON 0=OFF
iDelay = 30, -- Delay between each text file in minutes
-- Don't change this
iCnt = 1,
tPrefixes = {},
--------------------
}
sFile = { -- put here the files you want to send
"txt/file1.txt",
"txt/file2.txt",
"txt/file3.txt",
"txt/file4.txt",
}
--End User Settings-----------------------------------------------------------------
Main = function()
for a,b in pairs(frmHub:GetPrefixes()) do mSet.tPrefixes[b] = 1 end
SetTimer(mSet.iDelay*60*1000)
StartTimer()
end
ChatArrival = function(sUser, sData)
sData=string.sub(sData,1,-2)
local s,e,sPrefix,cmd = string.find(sData, "%b<>%s*(%S)(%S+)")
if sPrefix and mSet.tPrefixes[sPrefix] then
if sUser.bOperator then
local tCmds = {
["adon"] = function(user,data)
mSet.RunStatus = 1
user:SendData(mSet.sBot,"Messages started...")
OnTimer()
end,
["adoff"] = function(user,data)
mSet.RunStatus = 0
user:SendData(mSet.sBot,"Messages stopped...")
end,
}
if tCmds[cmd] then
return tCmds[cmd](sUser,sData),1
end
end
end
end
OnTimer = function()
if mSet.RunStatus == 1 then
for i = 1, table.getn(sFile) do
if i == mSet.iCnt then
local f,tmp = io.open(sFile[i],"r"),""
if f then
tmp = f:read("*a")--
tmp = string.gsub(tmp,"|",string.char(166))
tmp = string.gsub(tmp,"\n","\r\n")
f:close()
SendToAll(mSet.sBot,"\r\n"..tmp)
end
if table.getn(sFile) == i then
mSet.iCnt = 1
else
mSet.iCnt = i + 1
end
break
end
end
end
end
greetzz TT
Or this:
-- Rotating Message 1.1 by jiten - for PtokaX 0.3.3.0 build 16.09 or Higher
-- based on Rotating Message 1.0 by Mutor The Ugly
-- Rotates n text files posted to main chat at interval
-- Added: Rotates every .txt file stored in sFolder (by kepp)
-- Added: Text file sending by own trigger (Prefix - Filename)
mSet = {
sBot = frmHub:GetHubBotName(), -- Bot Name
RunStatus = 0, -- Auto Start -> 1=ON 0=OFF
iDelay = 30, -- Delay between each text file in minutes
sFolder = "txt", -- Folder where all the .txt files are stored
-- Don't change this
iCnt = 1,
}
sFile = {}
Main = function()
ReloadText()
SetTimer(mSet.iDelay*60*1000)
if (mSet.RunStatus == 1) then
StartTimer()
end
end
ChatArrival = function(sUser, sData)
sData=string.sub(sData,1,-2)
local s,e,cmd = string.find(sData, "%b<>%s+[%!%?%+%#](%S+)" )
if sUser.bOperator then
local tCmds = {
["adon"] = function(user,data)
mSet.RunStatus = 1
user:SendData(mSet.sBot,"Messages started...")
StartTimer()
end,
["adoff"] = function(user,data)
mSet.RunStatus = 0
user:SendData(mSet.sBot,"Messages stopped...")
StopTimer()
end,
["reload"] = function(user,data)
ReloadText()
user:SendData(mSet.sBot,"Textfiles loaded...")
end,
}
if tCmds[cmd] then
return tCmds[cmd](sUser,sData),1
else
local sContent = FileExists(mSet.sFolder.."/"..cmd..".txt")
if (sContent) then
return sUser:SendData(mSet.sBot,"\r\n"..sContent),1
end
end
end
end
OnTimer = function()
local TableSize = table.getn(sFile)
for i=1,TableSize do
if (i == mSet.iCnt) then
local sContent = FileExists(mSet.sFolder.."/"..sFile[i])
if (sContent) then
SendToAll(mSet.sBot,"\r\n"..sContent)
end
if (TableSize == i) then mSet.iCnt = 1 else mSet.iCnt = mSet.iCnt + 1 end
break
end
end
end
function FileExists(sFile)
local oFile = io.open(sFile,"r");
if (oFile) then
local line = oFile:read("*all");
oFile:close();
return string.gsub(line,"\r","\r\n");
else
return nil;
end
end
function ReloadText()
sFile = nil;
sFile = {};
collectgarbage();
--// Load up files to table from folder \\--
os.execute("dir /b "..mSet.sFolder.."\\*.txt > files.txt");
local hFile = io.open("files.txt","r");
local line = hFile:read();
while line do
table.insert(sFile,1,line)
line = hFile:read();
end
hFile:close();
os.remove("files.txt");
end
But now i cant set 2 times only one
I want to set time for message 1 in main to 120 minutes
and the message 2 for 210 minutes
so after 120 minutes message 1 appears and 120 minutes later again and 120 minutes later again
and message 2 appears after 210 minutes and 210 minutes later again and 210 minutes later again
if this possible
Try this:
-- Txtshow by bastya_elvtars
-- At preconfigured times it shows a text file.
Botname="Texter"
HubAD=
?{
? ?["18:00"]="blabla.txt",
? ?["22:33"]="thx.txt",
? ?["01:21"]="ReadMe.txt",
?}
--[[["HH:MM"]="filename.txt",
Can even be 18:33 if this is your perversion :)
Does not have to be a textfile reachable by command as well. :)
A textfile can be bound to any number of timestamps.
Just comment a line if you do not need it any longer, or rename the file to a non-existant.
Or, delete the file (if a file does not exist, there are gonna be no errors).
]] ?
-- The folder where your text files reside
-- Warning: NOT \ but /
folder="I:/!!!px2!!!"
-- // Don't edit below.
Timer=0
function OnTimer()
?local now=os.date("%H:%M")
?if Timer~=60 then
? ?Timer=Timer+1
?else
? ?if HubAD[now] then
local f=io.open(folder.."/"..HubAD[now],"r")
if f then
local contents = string.gsub(f:read("*a"),string.char(10), "\r\n")
SendToAll(Botname,"\r\n"..contents.."\r\n")
?f:close()
end
? ?end
? ?Timer=0
?end
end
function Main()
?SetTimer(1000)
?StartTimer()
end
gonna try it Hungarista
if it works its very cool with the time
it should work - it's also used as a plugin for lawmaker and works fine there
Thx Hungarista
Works fantastic many thx