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.
Maybe this:
BadFiles = function(PathStr)
for i, v in tBadFiles do
if string.find(PathStr, i) then
return v[1]
end
end
end
Thanx for you reply Jiten, but it doesn't seems to work :(
Any other suggestions? :)
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.
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....
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
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!!
Try changing return 1,tBadFiles[i][2]
return 1, v[1]
to:
return tBadFiles[i][2], 1
return v[1], 1
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...
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...
I think I have found the bug, in another function :(
But the function above here seems to be ok now...
Bit off:
Why not tBadFiles = {
["testfile "] = {
reason = "sharing temp files (incomplete) ",
hours = 10,
times = 18,
},
}
and recalled like this:
"kicked because:"..tBadFiles["testfile "].reason
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).
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 =)
%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
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
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
[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
problem fixed... needed to reg user again =)
thx for your help ;)