other table
 

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

other table

Started by TTB, 24 May, 2005, 13:59:48

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TTB

Hi,

I have this table:

tBadFiles = {
	{"[COLOR=red]testfile[/COLOR] " , "[COLOR=red]test[/COLOR] "},
	{"bla", "test"},
}
with function:
BadFiles = function(PathStr)
	for i = 1, table.getn(tBadFiles) do
		if string.find(PathStr, tBadFiles[i][1]) then
			return 1,tBadFiles[i][2]
		end
	end
	return nil, "Other Files"
end

But now I have this table:
tBadFiles = {
	["[COLOR=red]testfile[/COLOR] "] = {
		[1] = "[COLOR=red]sharing temp files (incomplete)[/COLOR] ",
		[2] = 10,
		[3] = 18,
	},
}
What should be the function like?? I tried some little things, but doesn't work... Or isn't it possible to change the function the way the new table now is?

*edited* >> Extra info. The code in red is where it is all about.
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

jiten

Maybe this:
BadFiles = function(PathStr)
	for i, v in tBadFiles do
		if string.find(PathStr, i) then
			return v[1]
		end	
	end
end

TTB

Thanx for you reply Jiten, but it doesn't seems to work   :(

Any other suggestions?  :)
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

jiten

QuoteOriginally posted by TTB
Thanx for you reply Jiten, but it doesn't seems to work   :(

Any other suggestions?  :)
Hum... have you noticed the extra space after "testfile"?
Maybe that's why it isn't working.
Have a close look at this one:
tBadFiles = {
	["test"] = {
		[1] = "sharing temp files (incomplete) ",
		[2] = 10,
		[3] = 18,
	},
}

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	for i, v in tBadFiles do
		if string.find(data, i) then
			SendToAll(v[1])
		end
	end
end

Best regards.

TTB

Thanx again Jiten...

I noticed the extra space... that's because I putted some color in the script, and I didn't noticed that. On my HD is the script without an extra space.

[15:03:15] sharing temp files (incomplete) 
[15:03:15] <[SU]TTB> testfile

Nice way to test indeed. And the code seems to work... Then I got another problem, but I don't know what. I will take a look @ it and try to find out what my problem now is. But what I don't understand, why is the first table working with this function, and the second one not....
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

jiten

QuoteOriginally posted by TTB
But what I don't understand, why is the first table working with this function, and the second one not....
Can you point me the first and second?
I got lost :D

TTB

Ghehe... explaination:

The script is a part of NightLitch BadFiles. I have some extra features added, and this is a function that calls the keys from the current table...

This is the function, that somehow doesn't work:
BadFiles = function(PathStr)
	for i,v in tBadFiles do
		if string.find(PathStr, i) then
			return 1, v[1]
		end	
	end
	return nil, "Other Files"
end

The code seems to be right because you posted it in the ChatArrival function, and it works when I enter a keyword what is in the table.

Some extra info:

tCall = {}
tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)
if Profiles[sUser.iProfile] == 1 then return 0 end
if Startbot == nil then return 0 end
	if Who == "SlotFetch" then
		local FileFound, FileReason = BadFiles(Path)
		if FileFound and tDelay[sUser.sName] == nil then
			warning(sUser,Path)
			warndelete(sUser,Path,FileReason,FileSize)
		end
	end
end

This is a function that calls the BadFiles function. I've searched the script for any other connection with the BadFiles function, but it isn't there. So these 2 functions are only connected to each other.

Now again the problem with only this table... This part works:

tBadFiles = {
	{"testfile" , "test"},
	{"bla", "test"},
}

BadFiles = function(PathStr)
	for i = 1, table.getn(tBadFiles) do
		if string.find(PathStr, tBadFiles[i][1]) then
			return 1,tBadFiles[i][2]
		end
	end
	return nil, "Other Files"
end
and this one doesn't work:
tBadFiles = {
	["testfile"] = {
		[1] = "sharing temp files (incomplete)",
		[2] = 10,
		[3] = 18,
	},
	["testfile02"] = {
		[1] = "sharing temp files (incomplete)",
		[2] = 10,
		[3] = 18,
	},
}



BadFiles = function(PathStr)
	for i,v in tBadFiles do
		if string.find(PathStr, i) then
			return 1, v[1]
		end	
	end
	return nil, "Other Files"
end

It is a critical point to have thisone working in my script, I hope it can be done..., and also hope you are not lost in the script atm :P

Thanx!!
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

jiten

#7
Try changing
return 1,tBadFiles[i][2]
return 1, v[1]
to:
return tBadFiles[i][2], 1
return v[1], 1

TTB

I don't get that, because the return is going to this function:

tCall = {}
tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)
if Profiles[sUser.iProfile] == 1 then return 0 end
if Startbot == nil then return 0 end
	if Who == "SlotFetch" then
		[COLOR=red]local FileFound, FileReason = BadFiles(Path)
		if FileFound and tDelay[sUser.sName] == nil then[/COLOR] 
			warning(sUser,Path)
			warndelete(sUser,Path,FileReason,FileSize)
		end
	end
end

Switching the 2 values won't give any result. Maybe I don't understand very well what you exactly mean...
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

jiten

My mistake. With all that text, I didn't give much attention to the related functions.
Well, try this then. Replace your function with this:
tCall = {}
tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)
if Profiles[sUser.iProfile] == 1 then return 0 end
if Startbot == nil then return 0 end
	if Who == "SlotFetch" then
		local FileFound, FileReason = BadFiles(Path)
		if FileFound and tDelay[sUser.sName] == nil then 
			SendToAll("works")
--			warning(sUser,Path)
--			warndelete(sUser,Path,FileReason,FileSize)
		end
	end
end
If the message "works" is sent, the badfile check is working well and the problem must be in the functions below SendToAll. If not, have a look at the tDelay table.
Not sure if this will help, but, who knows...

TTB

#10
I think I have found the bug, in another function  :(

But the function above here seems to be ok now...
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

bastya_elvtars

Bit off:

Why not
tBadFiles = {
	["testfile "] = {
		reason = "sharing temp files (incomplete) ",
		hours = 10,
		times = 18,
	},
}

and recalled like this:

"kicked because:"..tBadFiles["testfile "].reason
Everything could have been anything else and it would have just as much meaning.

TTB

Thanx for your reply... I will take a look @ it! Going crazy with all these tables, but got a lot of help (appreciate that very much).
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

Cêñoßy†ê

Could some help me little with little headache
How could i get this work
tCommands["addnetwork"] = function(user, data)
	if ScriptLevel.addnetwork[user.iProfile] == 1 then
		local s,e,cmd,minshare,name,addy = string.find[COLOR=red]( data, "%b<>%s+(%S+)%s+(%S+)%s+(%d+)%s+(%S+)" )[/COLOR] 
		if s then
				table.insert(NetworkTable,{minshare,name,addy})
				saveTableToFile(NetworkFile,NetworkTable,"NetworkTable")
				SendToAll(tSettings.BotName,tProfileName(user.iProfile).." "..user.sName.." added "..name.." to my network list!")
		else
			user:SendData(tSettings.BotName, "Right command is  !addnetwork 
!!!") end else user:SendData(tSettings.BotName, "You silly mortal... you can't make me obey you... with that profile!!!") end return 1 end

Result should be like :
NetworkTable = {
	[1] = {
		[1] = "1GB",
		[2] = "Testhub",
		[3] = "testhub.no-ip.org",
	},
}

thx ahead =)
Powered By Leviathan™ 2nd Generation v. 1.9

bastya_elvtars

%b<>%s+(%S+)%s+(%S+)%s+(%d+)%s+(%S+)

should be:

%b<>%s+(%S+)%s+(%S+)%s+(%S+)%s+(%S+)

because a hubname is not likely to be %d+

:-P
Everything could have been anything else and it would have just as much meaning.

Cêñoßy†ê

QuoteOriginally posted by bastya_elvtars
%b<>%s+(%S+)%s+(%S+)%s+(%d+)%s+(%S+)

should be:

%b<>%s+(%S+)%s+(%S+)%s+(%S+)%s+(%S+)

because a hubname is not likely to be %d+

:-P
Thx alot... works like a charm now ;)

[16:10:43]  
	----------------------------------Network Hubs----------------------------------
	 
	 Nr: [3]	 Min Share: 3gb	 Name: testhub3	 Address: testhub3.no-ip.org 
	 
	 Nr: [2]	 Min Share: 2gb	 Name: testhub2	 Address: testhub2.no-ip.org 
	 
	 Nr: [1]	 Min Share: 1gb	 Name: testhub	 Address: testhub.no-ip.org
Powered By Leviathan™ 2nd Generation v. 1.9

Cêñoßy†ê

Another small table prob :P

From:
RegTable = {
	["username"] = {
		[1] = "user_who_registered",
		[2] = "when registered ",
	},
}

i need to get it here:
tFunctions.userinfo = function(user, data)
	local s,e,cmd,name = string.find(data, "%b<>%s+(%S+)%s+(%S+)")
		if name then
	local victim = GetItemByName(name)
		if victim then
	local sTag = user.bHasTag
		if sTag then
	local border1 = "	 ---- --- ---- ---- ---- ---- ---- - USER INFO  ---- --- ---- ---- ---- ---- ---- -"
	local disp = "\r\n\r\n"..border1.."\r\n"
		disp = disp.."\r\n"
		disp = disp.."	Nick:			"..victim.sName.."\r\n"
		disp = disp.."	Password:		"..(frmHub:GetUserPassword(victim.sName) or "n/a").."\r\n"
		disp = disp.."	Ip:			"..victim.sIP.."\r\n"
		disp = disp.."	Sharesize:		"..ConvShare(victim.iShareSize).."\r\n"
		disp = disp.."	Profile:			"..(GetProfileName(victim.iProfile) or "User").."\r\n"
		disp = disp.."	Client:			"..(victim.sClient or "Unknown").." "..(victim.sClientVersion or "Unknown").."\r\n"
		disp = disp.."	Supports rightclick:		"..(tConvertSwitch4[victim.bUserCommand]).."\r\n"
		disp = disp.."	Connection:		"..(victim.sConnection or "n/a").." as "..(tConvertMode[victim.sMode] or "n/a").." mode\r\n"
		disp = disp.."	Hubs/Slots:		"..(victim.iHubs or "n/a").."  with "..(victim.iSlots or "n/a").." slots\r\n"
		disp = disp.."	Hubs as User:		"..(victim.iNormalHubs or "n/a").."\r\n"
		disp = disp.."	Hubs as Reg:		"..(victim.iRegHubs or "n/a").."\r\n"
		disp = disp.."	Hubs as Op:		"..(victim.iOpHubs or "n/a").."\r\n"
[COLOR=red]		disp = disp.."	Registered by:		\r\n"
		disp = disp.."	Registered when:		\r\n"[/COLOR] 
		disp = disp.."\r\n"
		user:SendPM(tSettings.BotName, disp)
				end
			end
		end
	return 1
end
Powered By Leviathan™ 2nd Generation v. 1.9

Cêñoßy†ê

[05:12] Syntax Leviathan/functions.lua:139: attempt to index field `?' (a nil value)

tFunctions.userinfo = function(user, data)
	local s,e,cmd,name = string.find(data, "%b<>%s+(%S+)%s+(%S+)")
		if name then
	local victim = GetItemByName(name)
		if victim then
	local sTag = user.bHasTag
		if sTag then
	local border1 = "	 ---- --- ---- ---- ---- ---- ---- - USER INFO  ---- --- ---- ---- ---- ---- ---- -"
	local disp = "\r\n\r\n"..border1.."\r\n"
		disp = disp.."\r\n"
		disp = disp.."	Nick:			"..victim.sName.."\r\n"
		disp = disp.."	Password:		"..(frmHub:GetUserPassword(victim.sName) or "n/a").."\r\n"
		disp = disp.."	Ip:			"..victim.sIP.."\r\n"
		disp = disp.."	Sharesize:		"..ConvShare(victim.iShareSize).."\r\n"
		disp = disp.."	Profile:			"..(GetProfileName(victim.iProfile) or "User").."\r\n"
		disp = disp.."	Client:			"..(victim.sClient or "Unknown").." "..(victim.sClientVersion or "Unknown").."\r\n"
		disp = disp.."	Supports rightclick:		"..(tConvertSwitch4[victim.bUserCommand]).."\r\n"
		disp = disp.."	Connection:		"..(victim.sConnection or "n/a").." as "..(tConvertMode[victim.sMode] or "n/a").." mode\r\n"
		disp = disp.."	Hubs/Slots:		"..(victim.iHubs or "n/a").."  with "..(victim.iSlots or "n/a").." slots\r\n"
		disp = disp.."	Hubs as User:		"..(victim.iNormalHubs or "n/a").."\r\n"
		disp = disp.."	Hubs as Reg:		"..(victim.iRegHubs or "n/a").."\r\n"
		disp = disp.."	Hubs as Op:		"..(victim.iOpHubs or "n/a").."\r\n"
[COLOR=red]		disp = disp.."	Registered by:		"..RegTable[victim.sName][1].."\r\n"[/COLOR] 
		disp = disp.."	Registered when:	"..RegTable[victim.sName][2].."\r\n"
		disp = disp.."\r\n"
		user:SendPM(tSettings.BotName, disp)
				end
			end
		end
	return 1
end
Powered By Leviathan™ 2nd Generation v. 1.9

Cêñoßy†ê

#18
problem fixed... needed to reg user again =)

thx for your help ;)
Powered By Leviathan™ 2nd Generation v. 1.9

SMF spam blocked by CleanTalk