Releasebot help =)
 

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 help =)

Started by zvamp, 06 April, 2005, 18:23:09

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zvamp

The releasebot I am using wont let REGs to add releases, only OPs are allowed to use the command +addrls, can someone please help me to fix this? so that REGs & VIPs also can add releases?

this is the code I use:

-- FreshStuff 3 - 3.7beta
-----------------------------------------------------------------------------------------
-- original idea/script by chilla
-- completely rewriten by plop
-- taken over by bastya_elvtars (the rock n' roll doctor)
-- if you were running 3.0 then you gotta delete the old file
-- it's incompatible with this version
-- deleting now goes by id number
-- anounces the new releas in mainchat
-----------------------------------------------------------------------------------------
--------------------------- 3.7 -----------------------------
-- converted to lua5 and added search function by bastya_elvtars
-- also taken over with permission by plop. :P
-- rewrote the metadata routine: pattern matching is applied upon opening, using nested arrays ---> faster.
-- added ability to delete multiple releases with a single line.
--------------------------- 3.7.5 -----------------------------
-- added choice between showing in main or PM on entry
-- new stuff is shown by real ID (idea by LiqUiD~TrolL)
-- security fixes have been made, corrupt entries are ignored
-----------------------------------------------------------------------------------------

senddebugto={"[TGA-OP]bastya_elvtars"}

-- Name the commands to what U like
-- This command adds stuff, syntax : +addalbum TYPE/CATAGORY THESTUFF2ADD
cmd1 = "+addrls"

-- This command shows the stuff, syntax : +albums with options new/game/warez/music/movie
cmd2 = "+rlsall"

-- This command deletes an entry, syntax : +delalbum THESTUFF2DELETE
cmd3 = "+delrls"

-- This command shows the latest stuff, syntax : +newalbums
cmd4 = "+rls"

-- This command reloads the txt file. syntax : +reloadalbums
-- (this command is needed if you manualy edit the text file)
cmd5 = "+reloadalbums"


-- This is for searching inside releases.

cmd6="+rlsfind"

-- Show latest stuff on entry 1=PM, 2=mainchat, 0=no
ShowOnEntry = 0

-- Max stuff shown on newalbums/entry
MaxNew = 40

-- The file storing the stuff
file = "releases.dat"


-- Name of the bot
Bot = "?Releases?"

-- you can add catagory's yourself ["trigger_name"]="catagory_name"
Types = {["Psychedelic"] = "Psychedelic", ["Ambient"]="Ambient", ["Electronic"]="Electronic", ["Psytrance"]="Psytrance", ["Goa"]="Goa", ["Chill"]="Chill", ["Psytrance"]="Psytrance", ["House"]="House", ["Proggresive"]="Proggresive", ["Trance"]="Trance", ["Psymovie"]="Psymovie"}

--------------------- don't change anything below here
AllStuff = {}
NewestStuff = {}

function Main()
frmHub:RegBot(Bot)
ReloadRel()
end

function Show(user)
if ShowOnEntry ~=0 then
if ShowOnEntry==1 then
user:SendPM(Bot, MsgNew.."|")
end
end
end

function NewUserConnected(user)
Show(user)
end

function ChatArrival(user,data)
data = string.sub(data,1,string.len(data)-1)
local _,_,cmd,type,tune = string.find(data, "%b<>%s+(%S+)%s*(%S*)%s*(.*)")
if cmd == cmd2 then
if type == "" then
user:SendPM(Bot, MsgAll.."|")
elseif type == "new" then
user:SendPM(Bot, MsgNew.."|")
elseif Types[type] then
ShowRelType(type)
user:SendPM(Bot, MsgType.."|")
end
return 1
elseif cmd == cmd4 then
user:SendPM(Bot, MsgNew.."|")
return 1
elseif user.bOperator then
if cmd == cmd3 then
if type ~= "" then
DelRel(user, type)
else
user:SendData(Bot, "yea right, like i know what i got 2 delete when you don't tell me!|")
end
return 1
elseif cmd == cmd1 then
if tune ~= "" and Types[type] then
AddRel(user, tune, type)
elseif Types[type] == nil then
user:SendData(Bot, "I need to know the catagory to add it to!|")
else
user:SendData(Bot, "yea right, like i know what you got 2 add when you don't tell me!|")
end
return 1
elseif cmd == cmd5 then
ReloadRel()
user:SendData(Bot, "Albums reloaded!|")
elseif cmd==cmd6 then
if type~="" and tune=="" then
SearchRel(user,type)
else
user:SendData(Bot, "yea right, like i know what you got 2 search when you don't tell me!|")
end

return 1
end
end
end


function OpenRel()
AllStuff = nil
NewestStuff = nil
AllStuff = {}
NewestStuff = {}
Count = 0
Count2 = 0
local f=io.open(file,"r")
if f then
for line in f:lines() do
Count = Count +1
local _,_,type,who,when,title=string.find(line, "(.+)$(.+)$(.+)$(.+)")
if type and who and when and title then
AllStuff[Count]={type,who,when,title}
else
SendToOps(Bot, "Releases file is corrupt, failed to load all items.")
end
end
f:close()
end
if Count > MaxNew then
local tmp = Count - MaxNew + 1
Count2=Count - MaxNew + 1
for i = tmp, Count do
Count2=Count2 + 1
if AllStuff[Count2] then
NewestStuff[Count2]=AllStuff[Count2]
end
end
else
for i=1, Count do
Count2 = Count2 + 1
if AllStuff then
NewestStuff[Count2]=AllStuff
end
end
end
end

function ShowRel(table)
Msg = "\r\n"
local type,who,when,title
if table == NewestStuff then
if Count2 == 0 then
MsgNew = "\r\n\r\n".." --------- The Latest Releases -------- \r\n\r\n  No releases on the list yet\r\n\r\n --------- The Latest Releases -------- \r\n\r\n"
else
for i=1, Count2 do
if NewestStuff then
type,who,when,title=NewestStuff[1],NewestStuff[2],NewestStuff[3],NewestStuff[4]
if title then
Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
else
Msg = Msg..(table.concat(NewestStuff)).."\r\n"
end
end
end
end
MsgNew = "\r\n\r\n".." --------- The Latest "..MaxNew.." Releases -------- "..Msg.."\r\n --------- The Latest "..MaxNew.."  Releases -------- \r\n\r\n"
else
if Count == 0 then
MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- \r\n\r\n  No releases on the list yet\r\n\r\n --------- All The Releases -------- \r\n\r\n"
else
MsgHelp = "  use "..cmd2.." for a,b in Types do
MsgHelp = MsgHelp.."/"..a
end
MsgHelp = MsgHelp.."> to see only the selected types"
for i=1, Count do
if AllStuff then
type,who,when,title=AllStuff[1],AllStuff[2],AllStuff[3],AllStuff[4]
if title then
Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
else
Msg = Msg..(table.concat(AllStuff)).."\r\n"
end
end
end
end
MsgAll = "\r\n\r\r\n".." --------- All The Releases -------- "..Msg.."\r\n --------- All The Releases -------- \r\n"..MsgHelp.."\r\n"
end
end

function ShowRelType(what)
local type,who,when,title
Msg = "\r\n"
tmp = 0
if Count == 0 then
MsgType = "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n\r\n  No "..string.lower(Types[what]).." yet\r\n\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
else
for i=1, Count do
type,who,when,title=AllStuff[1],AllStuff[2],AllStuff[3],AllStuff[4]
if type == what then
tmp = tmp + 1
Msg = Msg.."  "..when.." -- "..who.." -- "..title.."\r\n"
end
end
if tmp == 0 then
MsgType = "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n\r\n  No "..string.lower(Types[what]).." yet\r\n\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
else
MsgType= "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n"..Msg.."\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
end
end
end

function AddRel(user, what, type)
Count = Count + 1
AllStuff[Count]={type,user.sName,os.date("%x"),what}
user:SendData(Bot, what.." is added to the releases as "..type.."|")
SendToAll(Bot, user.sName.." added to the "..type.." releases: "..what.."|")
SaveRel()
ReloadRel()
end

function DelRel(user, what)
string.gsub(what,"(%d+)",function(what)
what = tonumber(what)
if what then
if AllStuff[what] then
local which=(AllStuff[what][4])
user:SendData(Bot, which.." is deleted from the releases|")
AllStuff[what]=nil
else
user:SendData(Bot, "release numbered "..what.." wasn't found in the releases|")
end
else
user:SendData(parseenv(user,env,Bot).. "I need the ID number to delete an entry.|")
end
end)
SaveRel()
ReloadRel()
end

function SaveRel()
local f= io.open(file,"w+")
for i=1,Count do
if AllStuff then
f:write(AllStuff[1].."$"..AllStuff[2].."$"..AllStuff[3].."$"..AllStuff[4].."\n")
end
end
f:flush()
f:close(f)
end

function ReloadRel()
OpenRel()
ShowRel(NewestStuff)
ShowRel(AllStuff)
end

function DelRelOld(user, what)
Okie = nil
local title
for a,b in AllStuff do
title=b[4]
if title == what then
AllStuff[a]=nil
user:SendData(Bot, what.." is removed from the releases|")
Okie = 1
break
end
end
if Okie then
SaveRel()
ReloadRel()
else
user:SendData(Bot, what.." wasn't found in the releases|")
end
end

function SearchRel(user,what)
local res=0
local rest={}
local _,_,bdc=string.find(what,"([%%%[%]%(%)%*%+%-%?%^])")
local msg="\r\n---------- You searched for keyword \""..what.."\". The results: ----------\r\n"
if bdc then
user:SendData(Bot,"you cannot use the character "..bdc)
return
end
for a,b in AllStuff do
if string.find(b[4],what) then
table.insert(rest,{b[1],b[2],b[3],b[4]})
end
end
if table.getn(rest)~=0 then
for i=1,table.getn(rest) do
local type,who,when,title=rest[1],rest[2],rest[3],rest[4]
res= res + 1
msg = msg.."\r\n  "..when.." -- "..who.." -- "..title
end
msg=msg.."\r\n\r\n"..res.." results."
else
msg=msg.."\r\nSearch string "..what.." was not found in releases database."
end
user:SendPM(Bot,msg)
end

function OnError(ErrorMsg)
if enabledebug==1 then
for f=1,table.getn(senddebugto) do
SendPmToNick(senddebugto[f],Bot, ErrorMsg.."\r\n".."Stack traceback: "..debug.traceback())
end
end
end

jiten

Replace you ChatArrival with this:

function ChatArrival(user,data)
	data = string.sub(data,1,string.len(data)-1) 
	local _,_,cmd,type,tune = string.find(data, "%b<>%s+(%S+)%s*(%S*)%s*(.*)")
	if cmd == cmd2 then
		if type == "" then
			user:SendPM(Bot, MsgAll.."|")
		elseif type == "new" then
			user:SendPM(Bot, MsgNew.."|")
		elseif Types[type] then
			ShowRelType(type)
			user:SendPM(Bot, MsgType.."|")
		end
		return 1
	elseif cmd == cmd4 then
		user:SendPM(Bot, MsgNew.."|")
		return 1
	elseif user.iProfile == 2 or user.iProfile == 3 then
		if cmd == cmd1 then
			if tune ~= "" and Types[type] then
				AddRel(user, tune, type)
				elseif Types[type] == nil then
				user:SendData(Bot, "I need to know the catagory to add it to!|")
			else
				user:SendData(Bot, "yea right, like i know what you got 2 add when you don't tell me!|")
			end
			return 1
		end
	elseif user.bOperator then
		if cmd == cmd3 then
			if type ~= "" then
				DelRel(user, type)
			else
				user:SendData(Bot, "yea right, like i know what i got 2 delete when you don't tell me!|")
			end
			return 1
		elseif cmd == cmd1 then
			if tune ~= "" and Types[type] then
				AddRel(user, tune, type)
				elseif Types[type] == nil then
				user:SendData(Bot, "I need to know the catagory to add it to!|")
			else
				user:SendData(Bot, "yea right, like i know what you got 2 add when you don't tell me!|")
			end
			return 1
		elseif cmd == cmd5 then
			ReloadRel()
			user:SendData(Bot, "Albums reloaded!|")
		elseif cmd==cmd6 then 
			if type~="" and tune=="" then
				SearchRel(user,type)
			else
				user:SendData(Bot, "yea right, like i know what you got 2 search when you don't tell me!|")
			end
		
		return 1
		end
	end
end

Cheers

zvamp

Syntax E:\0.3.3.0.b16.09.nt.dbg\scripts\releasebot.lua:248: attempt to call global `OpenRel' (a nil value)

i get this message when i do =((

jiten

Working well with me. I don't get that error.

PS: I recommend u using FreshStuff 3.5. From the ones i used, it is the more stable.

zvamp

i now got it to work =)) thanks man !!

jiten

QuoteOriginally posted by zvamp
i now got it to work =)) thanks man !!

Cool  :]

SMF spam blocked by CleanTalk