PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: LILLITH on 08 March, 2005, 18:28:01

Title: =ReleaseBot= request
Post by: LILLITH on 08 March, 2005, 18:28:01
Hello!

Can someone convert =ReleaseBot= (the one that came with Robocop 8.x versions) in LUA 5, please?

Thanx in advance!  :)


-- Verry simple release script nothing fancy
-- Make a file called releases.txt in \Scripts Folder
-- Made By Optimus

sBot = "=ReleaseBot="

timedate = date()
file = "releases.txt"

display1 = "Item"
display2 = "Description"
display3 = "Releases"

function Main()
frmHub:RegBot(sBot)
end

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
_,_,cmd=strfind(data, "%b<>%s+(%S+)")

if (cmd=="!read") then
ReadRelease(user, data, cmd)
return 1

elseif (cmd=="!write") then
if user.bOperator or user.iProfile == 2 then
s,e,cmd,release,desc = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

if desc == nil then
description = "No "..display2.." specified!"
s,e,cmd,release = strfind( 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 !read in Main-Chat to show "..display1..".")
return 1
else
user:SendData(sBot, "*** !write is only availible to [VIP] and above!")
return 1
end
end
end
end

function ReadRelease(user, data, cmd)
local release = ""
readfrom(file)
while 1 do
local line = 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()
end

function News(what)
appendto(file)
write(what.."\n")
writeto()
end
Title:
Post by: 6Marilyn6Manson6 on 09 March, 2005, 11:01:21
-- 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

sBot = "=ReleaseBot="

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=="!read") then
ReadRelease(user, data, cmd)
return 1

elseif (cmd=="!write") 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 !read in Main-Chat to show "..display1..".")
return 1
else
user:SendData(sBot, "*** !write is only availible to [VIP] and above!")
return 1
end
end
end
end

function ReadRelease(user, data, cmd)
local release = ""
readfrom(file)
while 1 do

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()
end

function News(what)
appendto(file)
write(what.."\n")
writeto()
end

bye bye
Title:
Post by: LILLITH on 09 March, 2005, 11:06:23
Thank you very much but... i have this error:

...scripts\release_bot.lua:8: attempt to index global `timeos' (a nil value)
Title:
Post by: 6Marilyn6Manson6 on 09 March, 2005, 11:13:24
You're Italian?
Title:
Post by: LILLITH on 09 March, 2005, 11:20:03
QuoteOriginally posted by 6Marilyn6Manson6
You're Italian?

Yup! :)

I edited my previous post... i have en error! If you can help i'd appreciate it very much! :)
Title:
Post by: 6Marilyn6Manson6 on 09 March, 2005, 11:23:47
Be anch'io sono italiano, cmq dammi l'indirizzo del tuo hub, lo incolli pure qui se vuoi e vediam oassieme gli errori :)
Title:
Post by: LILLITH on 09 March, 2005, 11:27:55
Oh, si pu? parlare in italiano qua?

Cmq, il bot non parte proprio quando lo avvio! Non mi viene neanche spuntato...

L'indirizzo ? metalonly.no-ip.com
Title:
Post by: 6Marilyn6Manson6 on 09 March, 2005, 11:34:29
Urca non posso entrare causa troppi hub.. dovrei aprrie un secondo client e ora non posso. Ho usato il ocnvertitore di NightLitch e non so perk? non va oltretutto non telo carica nemmeno, prova a spuntarlo manualmente vedi se ti esce qualche errore
Title:
Post by: LILLITH on 09 March, 2005, 11:39:00
Ti ho mandato PM! :)
Title:
Post by: Herodes on 09 March, 2005, 12:25:46
hmm ... english was good also ... ;)
Title:
Post by: LILLITH on 09 March, 2005, 12:31:33
Oh sorry!

Well, if you need it, the code that 6Marylin6Manson6 posted work now! The bot loads!

But actually at the moment can't make it work...

The commands are not responding... :/
Title:
Post by: Madman on 09 March, 2005, 19:01:14
Change DataArrival to ChatArrival it should work then
Title:
Post by: Madman on 10 March, 2005, 09:10:59
fixed the file handling problem

-- 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 = "=ReleaseBot="

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=="!read") then
ReadRelease(user, data, cmd)
return 1

elseif (cmd=="!write") 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 !read in Main-Chat to show "..display1..".")
return 1
else
user:SendData(sBot, "*** !write 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
Title:
Post by: Madman on 10 March, 2005, 09:14:30
Requested by Shalla
Fixed so anyone can use !write not just vips and above

-- 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
-- Requested by Shalla
-- Fixed so anyone can use !write not just vips and above

sBot = "=ReleaseBot="

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)
s,e,cmd=string.find(data, "%b<>%s+(%S+)")

if (cmd=="!read") then
ReadRelease(user, data, cmd)
return 1

elseif (cmd=="!write") then
local s,e,cmd,release,desc = string.find( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

if desc == nil then
description = "No "..display2.." specified!"
local 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 !read in Main-Chat to show "..display1..".")
return 1
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
Title:
Post by: (-=TrIp-iN-SuN=-) on 10 March, 2005, 12:46:26
any one know how changed this script to lua5?




--## Release Bot Re-Written

--## Removed some functions to xxx

--## Made by xxx

--## Commands:

--##+add - Will add a Release to the list

--##+del - Will deleted a Relese from the list

--##+rlsall- Will Show all the Releases

--##+rls- Will Show the Lastest Releases

--##+rlsfind - Will make a search for a Release



sBot = "-NemO-"



arrRelease = {}

fDataRelease = "release.dat"

fRelease = "release.work"



--## Configuration ##--



iLastRelease = 30 -- Choose how many new release you want to show in +rls

uLaterPtokax = 0-- Choose 0 if you are using Ptokax version 0.3.3.0 or higher

-- Choose 1 if you are using Ptokax version lower then 0.3.3.0



--## END ##--



function Main()

frmHub:RegBot(sBot)

LoadFromFile(fDataRelease)

end



function OnExit()

SaveToFile(fDataRelease , arrRelease , "arrRelease")

end



function DataArrival(user, data)

if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: Psychedelic~Dreams2"..sBot) then

data = strsub(data,1,strlen(data)-1)

s,e,cmd = strfind(data, "%b<>%s+(%S+)")

if (cmd == "+add" and user.bOperator) then

LoadFromFile(fDataRelease)

AddRelease(user, data)

if (uLaterPtokax == 0) then

OnExit()

end

arrRelease = {}

return 1

elseif (cmd == "+rlsall") then

ShowAllRelease(user)

return 1

elseif (cmd == "+rls") then

ShowLastestReleases(user)

return 1

elseif (cmd == "+del" and user.bOperator) then

LoadFromFile(fDataRelease)

DeleteRelease(user, data)

if (uLaterPtokax == 0) then

OnExit()

end

arrRelease = {}

return 1

elseif (cmd == "+rlsfind") then

FindRelease(user, data)

return 1

end

end

end



function AddRelease(user, data)

local s,e,rel,style = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)")

if (rel == nil or style == nil) then

user:SendData(sBot, "Syntax Error, +addrls