Can someone do very simple relase bot where is only write-, read- and deletecommands. And it have to be LUA 5.
Very Simple enjoy!!!
-- Verry simple release script nothing fancy
-- Make a file called releases.txt in \Scripts Folder
-- Made By Optimus
-- Converted the script into LUA 5 by 6Marilyn6Manson6
-- Filehandling problem fixed by Madman
sBot = "??Rls-Bot??"
timedate = os.date()
file = "releases.txt"
display1 = "Item"
display2 = "Description"
display3 = "Releases"
function Main()
frmHub:RegBot(sBot)
end
function ChatArrival(user, data)
if (string.sub(data, 1, 1) == "<" ) then
data=string.sub(data,1,string.len(data)-1)
_,_,cmd=string.find(data, "%b<>%s+(%S+)")
if (cmd=="+rls") then
ReadRelease(user, data, cmd)
return 1
elseif (cmd=="+addrls") then
if user.bOperator or user.iProfile == 2 then
s,e,cmd,release,desc = string.find( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )
if desc == nil then
description = "No "..display2.." specified!"
s,e,cmd,release = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
else
description = desc
end
if release == nil then
user:SendData(sBot, "*** No "..display1.." specified!")
return 1
end
News("By: "..user.sName.."\t Date: "..timedate.."\r\n"..display1..": "..release.."\r\n"..display2..": "..description.."\r\n")
SendToAll(sBot, "New "..display3.." Added....By <"..user.sName.."> Type +rls in Main-Chat to show "..display1..".")
return 1
else
user:SendData(sBot, "*** +addrls is only availible to [VIP] and above!")
return 1
end
end
end
end
function ReadRelease(user, data, cmd)
local release = ""
-- readfrom(file)
local file = io.input(file);
while 1 do
local line = io.read()
if (line == nil) then
break
else
release = release.." "..line.."\r\n"
end
end
user:SendPM(sBot, "\r\n\r\n".." "..display3.."s posted by users: ".."\r\n\r\n"..release)
-- readfrom()
file:read()
end
function News(what)
-- appendto(file)
-- write(what.."\n")
-- writeto()
local file = io.open(file, "a+") -- "a+"
file:write(what.."\n")
file:close()
end
Ferocious Beast, next time try posting the scripts with the [ CODE] [ /CODE] thing (without the space between the "[" and "C" ;)
Best regards.
Can somebody add to that script the Delete-command??
QuoteOriginally posted by Mara
Can somebody add to that script the Delete-command??
Get freshstuff for anything more advanced than this.. much much better ..
Hi i wanted to know how to make the releases come up in Pm rather than Main chat. Does anyone know how to do that or wat to change. thank you
Wanna give this one a try ?
-- Verry simple release script nothing fancy
-- Make a file called releases.txt in \Scripts Folder
-- Made By Optimus
-- Converted the script into LUA 5 by 6Marilyn6Manson6
-- Filehandling problem fixed by Madman
--- touched by Herodes
sBot = {
name = "??Rls-Bot??",
email = "some.email.com",
desc = "This is the simplest release bot ever!",
}
timedate =
display1 = "Item"
display2 = "Description"
display3 = "Releases"
function Main()
frmHub:RegBot(sBot.name, 1, sBot.desc, sBot.email)
sBot = sBot.name
end
function ChatArrival(user, data)
data = string.sub(data,1,-2)
_,_,cmd=string.find(data, "%b<>%s+(%S+)")
if (cmd=="+rls") then
ReadRelease(user, data, cmd)
return 1
elseif (cmd=="+addrls") then
if user.bOperator or user.iProfile == 2 then
s,e,cmd,release,desc = string.find( data, "%b<>%s+(%S+)%s+(%S+)%s*(.*)" )
if not release then
user:SendData(sBot, "*** No "..display1.." specified!")
return 1
end
News("By: "..user.sName.."\t Date: "..os.date().."\r\n"..display1..": "..release.."\r\n"..display2..": "..(desc or "No "..display2.." specified!").."\r\n")
SendToAll(sBot, "New "..display3.." Added....By <"..user.sName.."> Type +rls in Main-Chat to show "..display1..".")
else
user:SendData(sBot, "*** +addrls is only availible to [VIP] and above!")
end
return 1
end
end
function ReadRelease(user, data, cmd)
local f = io.input("releases.txt");
if f then
local m = ""
for line in f:lines() m = m..line.."\n" end
f:close()
user:SendPM(sBot, "\r\n\r\n\t\t"..display3.."s posted by users: ".."\r\n\r\n"..m)
end
end
function News(what)
local f = io.open(file, "a+")
f:write(what.."\n")
f:close()
end