=ReleaseBot= request
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

=ReleaseBot= request

Started by LILLITH, 08 March, 2005, 18:28:01

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LILLITH

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

6Marilyn6Manson6

#1
-- 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

LILLITH

#2
Thank you very much but... i have this error:

...scripts\release_bot.lua:8: attempt to index global `timeos' (a nil value)

6Marilyn6Manson6


LILLITH

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! :)

6Marilyn6Manson6

Be anch'io sono italiano, cmq dammi l'indirizzo del tuo hub, lo incolli pure qui se vuoi e vediam oassieme gli errori :)

LILLITH

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

6Marilyn6Manson6

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

LILLITH

Ti ho mandato PM! :)

Herodes

hmm ... english was good also ... ;)

LILLITH

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... :/

Madman

Change DataArrival to ChatArrival it should work then
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

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
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

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
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

(-=TrIp-iN-SuN=-)

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