determinate determinate

Author Topic: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]  (Read 5920 times)

0 Members and 1 Guest are viewing this topic.

Offline merlin_xl54

  • Forum Ace
  • *****
  • Posts: 91
  • Karma: +2/-0
  • Not a player, just Playing!
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #35 on: October 21, 2008, 09:07:06 pm »
Hi Mutor,

The script works perfectly and has helped our hub more than you know. Is there a way for you to code so a blocked user could download from a specific nick (added to the script) similar to the excluded nick check?

We have a nick which only shares our rules and required files. I would like the script to work as it does, but also allow blocked users to download from that nick only.

TIA

M
Living is easy with eyes closed.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
OmniBlocker 1.0e LUA 5.1x [Strict][API 2]
« Reply #36 on: October 22, 2008, 12:18:04 am »
As you wish. Allows for a single nick.
To enable, set:
Code: [Select]
Inc = "NickName",or
Code: [Select]
Inc = false,to disable.

Code: [Select]
--[[

OmniBlocker 1.0e LUA 5.1x [Strict][API 2]

By Mutor 03/18/08

Yet another block bot, nothing new here but the code method. :P
Naturally the same limitiations exist as the protocol is the same.

-Blocks uploads and downloads from specified profiles or users
-Exclusion table for protected nick within blocked profiles
-Operator command/menu to toggle user block on/off
-Both blocked/unblocked users are informed of a blocked xfer
-Blocked user data saved to file for hub/script restarts.


+Changes from 1.0 03/18/08
+Added search block for blocked users

+Changes from 1.0b 05/31/08
+Added (optional) block/unblock toggle message to nick. Requested by ExtreeM

+Changes from 1.0c 09/10/08
+Added option for user blocks to be permanent or not
~Extended fraudulent search to include free slot and TTH root

+Changes from 1.0d 09/10/08
+Added option for a single nick that blocked users may download from. requested by merlin_xl54

]]

Cfg = {
-- "BotName" ["" = hub bot]
Bot = "[OmniBlock]",
-- Bot description
Desc = "I block file transfers and searches",
--Bot Email address
Mail = "user@domain.com",
-- Should bot have a key? true/false
BotIsOp = true,
-- Admins nick for status / error messages
OpNick = "Mutor",
--"Command SubMenu" ["" = script name]
SubMenu = "",
-- Context Menu Title ["" = hub name]
Menu = "",
-- File to save exlusion table
File = Core.GetPtokaXPath().."scripts/OmniBlock.dat",
-- Set your profiles / permissions here.
-- profile_idx = true/false, [Block transfers, true = yes / false = no]
Profiles = {
[-1] = true, --Unregistered User
[0] = false, --Master
[1] = false, --Operator
[2] = false, --Vip
[3] = false, --Registered User
},
-- Exclude these nicks from check
Exc = {
["Mutor"] = true,
["WebReg"] = true,
},
-- List here a single nick that blocked users may download from. ["Nick" as string or false = disable]
Inc = false,
-- Number of warns before user is kicked. [0 = disabled]
MaxWarn = 7,
-- Unblocking user in a blocked profile is temporary? true/false [per script session]
TempBlock = true,
}
local Xfer,Search = {},{}
OnStartup  = function()
Cfg.MaxWarn,Cfg.Scp = math.min(Cfg.MaxWarn,10),"OmniBlocker 1.0e"
if Cfg.Bot == "" then Cfg.Bot = SetMan.GetString(21) end
if Cfg.Menu == "" then Cfg.Menu = SetMan.GetString(0) end
if Cfg.SubMenu == "" then Cfg.SubMenu = Cfg.Scp end
if Cfg.Bot ~= SetMan.GetString(21) then Core.RegBot(Cfg.Bot, Cfg.Desc,Cfg.Mail,Cfg.BotIsOp) end
if loadfile(Cfg.File) then dofile(Cfg.File) else Block = {} Save() end
local chg = false
for _,user in ipairs(Core.GetOnlineUsers()) do
local Chk = function(nick)
for i,v in pairs(Block) do if i:lower() == nick:lower() then return true end end
end
local p,n = user.iProfile,user.sNick
if not Cfg.Exc[n] then
if Cfg.Profiles[p] then
if Cfg.TempBlock then
if not Block[n] then Block[n] = true chg = true end
else
if not Chk(n) then Block[n] = true chg = true end
end
end
end
end
for n,v in pairs(Block) do
local t,p = RegMan.GetReg(n),-1
if t then p = t.iProfile end
if Cfg.Exc[n] or not Cfg.Profiles[p] then Block[n] = nil chg = true end
end
if chg then Save() end
assert(loadfile(Cfg.File))
end

OnError = function(msg)
local user = Core.GetUser(Cfg.OpNick)
if user then Core.SendToUser(user,"<"..Cfg.Bot.."> "..msg.."|") end
end

UserConnected = function(user)
local p,n,pfx = user.iProfile,user.sNick,SetMan.GetString(29):sub(1,1)
if p and n and pfx then
if not Cfg.Exc[n] then if Cfg.Profiles[p] and not Block[n] then Block[n] = true Save() end end
if Core.GetUserValue(user,11) then
local uc = "$UserCommand 1 1 "..Cfg.Menu.."\\"..Cfg.SubMenu.."\\Toggle User Block"..
"$<%[mynick]> "..pfx.."block %[line:Nickname (Case Sensitive)]&#124;|$UserCommand 1 2 "..
Cfg.Menu.."\\"..Cfg.SubMenu.."\\Toggle User Block".."$<%[mynick]> "..pfx.."block %[nick] "..
"%[line: Reason (Optional)]&#124;|"
Core.SendToUser(user,uc)
end
else
return true
end
end
OpConnected,RegConnected = UserConnected,UserConnected

UserDisconnected = function(user)
if Xfer[user.sNick] then if Xfer[user.sNick] >= Cfg.MaxWarn then Xfer[user.sNick] = nil end end
if Search[user.sNick] then if Search[user.sNick] >= Cfg.MaxWarn then Search[user.sNick] = nil end end
end
RegDisconnected, OpDisconnected = UserDisconnected,UserDisconnected

ChatArrival = function(user,data)
if Core.GetUserValue(user,11) then
local _,_,cmd = data:lower():find("^%b<> (["..SetMan.GetString(29).."]block) ")
local _,_,nick = data:find("^%b<> [^ ]+ ([^ |]+)|?")
local _,_,rsn = data:find("^%b<> [^ ]+ [^ ]+ ([^|]+)|$")
if cmd and nick then
local tab = RegMan.GetReg(nick)
if not tab or not ProfMan.GetProfile(tab.iProfile).tProfilePermissions.bIsOP then
local x,t = Block[nick],{["true"]= "blocked",["false"] = "unblocked"}
if x then x = false else x = true end Block[nick] = x
local s = t[tostring(x)]
if rsn then
local usr = Core.GetUser(nick)
local prof = ProfMan.GetProfile(user.iProfile).sProfileName
if usr then
Core.SendToUser(usr,"<"..Cfg.Bot.."> Your search and transfers "..
"are being "..s.." by "..prof.." "..user.sNick.." because:"..rsn.."|")
end
end
return Save(),Core.SendToUser(user,"<"..Cfg.Bot.."> "..nick..
"'s transfers are "..s.."|"),true
end
end
end
end

ConnectToMeArrival = function(user,data)
local p,n = user.iProfile,user.sNick
local Ctms = {[1] = "^$ConnectToMe ([^ ]-) ",[2] = "^$RevConnectToMe [^ ]- (.+)",}
if Block[n] then
if Cfg.Inc then
for i,v in ipairs(Ctms) do
local _,_,s = data:sub(1,-2):find(v)
if s and s:lower() == Cfg.Inc:lower() then return end
end
end
if Cfg.MaxWarn > 0 then
if Xfer[n] then Xfer[n] = Xfer[n] + 1 else Xfer[n] = 1 end
if Xfer[n] >= Cfg.MaxWarn then
return Core.Kick(user,Cfg.Bot,Cfg.MaxWarn.."x blocked transfer attempts."),true
end
end
return Core.SendToUser(user,"<"..Cfg.Bot.."> Your transfers are blocked. "..
"Please clear this transfer from your download queue. Thank you.|"),true
end
for i,v in ipairs(Ctms) do
local _,_,s = data:sub(1,-2):find(v)
if s and Block[s] then
return Core.SendToUser(user,"<"..Cfg.Bot.."> You requested a file from "..
s:format("%q")..", transfers from this user are blocked.|"),
Core.SendToUser(user,"<"..Cfg.Bot.."> Please clear "..string.format("%q",s)..
" from your download queue. Thank you.|"),true
end
end
end
RevConnectToMeArrival = ConnectToMeArrival

SearchArrival = function (user,data)
local p,n = user.iProfile,user.sNick
if Block[n] then
if Cfg.MaxWarn > 0 then
if Search[n] then Search[n] = Search[n] + 1 else Search[n] = 1 end
if Search[n] >= Cfg.MaxWarn then
return Core.Kick(user,Cfg.Bot,Cfg.MaxWarn.."x blocked search attempts."),true
end
end
local _,_,search = string.find(data,"([^?]+)|$")
if search then
local t = "TTH:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"--hash(t) in lieu of hub(h)
local h,b,i,u = SetMan.GetString(0),SetMan.GetString(21),
SetMan.GetString(3):gsub(";.*",""),SetMan.GetString(4)
local res = "Unknown Path"..string.char(92)..n..", search is "..
"disabled for you :P "..string.rep("\t",15)..search
return Core.SendToUser(user,"$SR "..b.." "..res.." 0 1/2"..t.." ("..i..":"..u..")|"..
"<"..Cfg.Bot.."> "..n..", search is disabled for you. Please close the "..
string.format("%q",search:gsub("%$"," ")).." search window. Thank you.|"),true
end
return true
end
end

SaveFile = function(File,table, tablename )
local hFile = io.open (File , "wb")
assert(hFile)
Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end

Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

Save = function() SaveFile(Cfg.File,Block,"Block") end
« Last Edit: March 13, 2010, 02:10:44 pm by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline merlin_xl54

  • Forum Ace
  • *****
  • Posts: 91
  • Karma: +2/-0
  • Not a player, just Playing!
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #37 on: November 23, 2008, 06:57:46 pm »
Hi Mutor,

Is there anyway to exclude blocked users when using a multi-source client? If users do not download directly from a blocked user, but have a multi-source client it will of course automatically look for available segments, and the script will send the default message "You requested a file from" etc.

I was not sure if the message could not be sent for segments while still keeping a user blocked.

TIA

M
Living is easy with eyes closed.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #38 on: November 23, 2008, 07:02:01 pm »
Considering the fact the segments may be downloaded from
users in other hubs I'm not aware of anyway to do this.
The script should block any CTM/RTCM requests by users
within the hub. $MultiConnectToMe's are not filtered.
« Last Edit: November 23, 2008, 07:05:46 pm by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline HaArD

  • Double Ace
  • *
  • Posts: 105
  • Karma: +2/-1
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #39 on: November 24, 2008, 02:43:56 pm »
I don't think MultiConnectToMe is your issue.... The last client to support that command was oDC, as for hubs, none have ever supported it besides the original NeoModus.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #40 on: November 24, 2008, 10:55:13 pm »
No doubt, and why although PtokaX has an arrival for it, I didn't bother with it.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline merlin_xl54

  • Forum Ace
  • *****
  • Posts: 91
  • Karma: +2/-0
  • Not a player, just Playing!
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #41 on: March 12, 2010, 03:21:42 pm »
Hi mutor,

Using 1.0e with PtokaX 0.4.1.2.

*Blocking
When I block from Hub tab I get the following. It allows for no message. Also the block is saved in the .dat file. No message to blocked user.
[08:56:15] <Bot> merlin_xl54@test
[08:56:15] *** 's transfers are blocked

Then I block from nick list. It gives optional message. Also the block is saved in the .dat file. * Now nick is listed twice in .dat. Message sent.
[08:56:39] <Bot> merlin_xl54@test's transfers are blocked
user message
[08:57:20] <Bot> Your search and transfers are being blocked by Master merlin_xl54 because:Testing

*Unblocking
From Hub tab
[08:57:24] <Bot> merlin_xl54@test
[08:57:24] *** 's transfers are unblocked
From nick list
[08:58:01] <Bot> merlin_xl54@test's transfers are unblocked
user message
[08:58:42] <Bot> Your search and transfers are being unblocked by Master merlin_xl54 because:Testing

When I unblock same as above, .dat changed to false for first unblock then false after second unblock.

I don't usually block from the Hub tab and never noticed this before.

TIA

M
Living is easy with eyes closed.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #42 on: March 13, 2010, 12:30:31 am »
The same nick cannot be listed twice in the Block table.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline merlin_xl54

  • Forum Ace
  • *****
  • Posts: 91
  • Karma: +2/-0
  • Not a player, just Playing!
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #43 on: March 13, 2010, 04:39:16 am »
The same nick cannot be listed twice in the Block table.

I checked my block table. It seems to be putting a pipe after one of the nicks. Not sure why? It's not part of the nick.

M
Block = {
   ["merlin_xl54@test"] = false,
   ["merlin_xl54@test|"] = false,
   
Living is easy with eyes closed.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #44 on: March 13, 2010, 02:13:29 pm »
Made a small correction in ChatArrival and updated script above [1.0e]
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline DeAn

  • Forum Ace
  • *****
  • Posts: 88
  • Karma: +0/-13
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #45 on: March 18, 2010, 05:28:51 pm »
Has this script been earlier made for API 1 version of Ptokax 0.3.6.0 ?
If yes, what was its name ?

Thanks,
DeAn
Thanks,

DeAn

Offline 4uvak91

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-4
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #46 on: April 03, 2010, 05:26:09 pm »
Code: [Select]
Profiles = {
[-1] = true, --Unregistered User
[0] = false, --Owner
[1] = false, --Admin
[2] = false, --SOP
[3] = false, --OP
[4] = false, --VIP-OP
[5] = false, --VIP
},

I noticed that this script block unreg user from search and at the same time owner can't get his Filelist, is it possible to make owner to get filelist but unreg user still can't search/download from the hub

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #47 on: April 03, 2010, 08:45:19 pm »
If you allow the op to get the user's file list, that user can then download from the op.
This is the nature of the NMDC protocol. You can't selectively block the transfer between
clients with hubside script.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline 4uvak91

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-4
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #48 on: April 03, 2010, 10:47:25 pm »
okay...hmm, but there is feature in DiXBoT that you can block only search, but i don't wanna use DiXBoT. So what about Auto-Block (your script) does it block only search and is possible to take off timeban feature  ???

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
OmniBlocker 1.0g LUA 5.1x [Strict][API 2]
« Reply #49 on: April 04, 2010, 06:19:40 pm »
Code: [Select]
--[[

OmniBlocker 1.0g LUA 5.1x [Strict][API 2]

By Mutor 03/18/08

Yet another block bot, nothing new here but the code method. :P
Naturally the same limitiations exist as the protocol is the same.

-Blocks uploads and downloads from specified profiles or users
-Exclusion table for protected nick within blocked profiles
-Operator command/menu to toggle user block on/off
-Both blocked/unblocked users are informed of a blocked xfer
-Blocked user data saved to file for hub/script restarts.


+Changes from 1.0 03/18/08
+Added search block for blocked users

+Changes from 1.0b 05/31/08
+Added (optional) block/unblock toggle message to nick. Requested by ExtreeM

+Changes from 1.0c 09/10/08
+Added option for user blocks to be permanent or not
~Extended fraudulent search to include free slot and TTH root

+Changes from 1.0d 09/10/08
+Added option for a single nick that blocked users may download from. requested by merlin_xl54

+Changes from 1.0f 04/04/10
~Blocking searches now optional, requested by 4uvak91
]]

Cfg = {
-- "BotName" ["" = hub bot]
Bot = "[OmniBlock]",
-- Bot description  ["" = script name]
Desc = "I block file transfers and searches",
--Bot Email address
Mail = "user@domain.com",
-- Should bot have a key? true/false
BotIsOp = true,
-- Admins nick for status / error messages
OpNick = "Mutor",
--"Command SubMenu" ["" = script name]
SubMenu = "",
-- Context Menu Title ["" = hub name]
Menu = "",
-- File to save exlusion table
File = "OmniBlock.dat",
-- Set your profiles / permissions here.
-- profile_idx = true/false, [Block transfers, true = yes / false = no]
Profiles = {
[-1] = true, --Unregistered User
[0] = false, --Master
[1] = false, --Operator
[2] = false, --Vip
[3] = false, --Registered User
},
-- Block Searches from blocked users also? [false = Search enabled]
NoSearch = true,
-- Exclude these nicks from check
Exc = {
["Mutor"] = true,
["WebReg"] = true,
},
-- List here a single nick that blocked users may download from. ["Nick" as string or false = disable]
Inc = false,
-- Number of warns before user is kicked. [0 = disabled]
MaxWarn = 7,
-- Unblocking user in a blocked profile is temporary? true/false [per script session]
TempBlock = true,
-- Always send script replies in private message?
OnlyPm = true,
}
local Xfer,Search = {},{}
OnStartup  = function()
Cfg.MaxWarn,Cfg.Scp,Cfg.Path = math.min(Cfg.MaxWarn,10),"OmniBlocker 1.0g",Core.GetPtokaXPath().."scripts/"

if Cfg.Menu == "" then Cfg.Menu = SetMan.GetString(0) end
if Cfg.SubMenu == "" then Cfg.SubMenu = Cfg.Scp end
if Cfg.Desc == "" then Cfg.Desc = Cfg.Scp end
if Cfg.Bot == "" then Cfg.Bot = SetMan.GetString(21) else Core.RegBot(Cfg.Bot,Cfg.Desc,Cfg.Mail,Cfg.BotIsOp) end
if not Cfg.File:find("^"..Cfg.Path,1,true) then Cfg.File = Cfg.Path..Cfg.File end
if loadfile(Cfg.File) then dofile(Cfg.File) else Block = {} Save() end
local chg = false
for _,user in ipairs(Core.GetOnlineUsers()) do
local Chk = function(nick)
for i,v in pairs(Block) do if i:lower() == nick:lower() then return true end end
end
local p,n = user.iProfile,user.sNick
if not Cfg.Exc[n] then
if Cfg.Profiles[p] then
if Cfg.TempBlock then
if not Block[n] then Block[n] = true chg = true end
else
if not Chk(n) then Block[n] = true chg = true end
end
end
end
end
for n,v in pairs(Block) do
local t,p = RegMan.GetReg(n),-1
if t then p = t.iProfile end
if Cfg.Exc[n] or not Cfg.Profiles[p] then Block[n] = nil chg = true end
end
if chg then Save() end
if not Cfg.NoSearch then SearchArrival = nil end
assert(loadfile(Cfg.File))
end

OnError = function(msg)
local user = Core.GetUser(Cfg.OpNick)
if user then Core.SendToUser(user,"<"..Cfg.Bot.."> "..msg.."|") end
end

UserConnected = function(user)
local p,n,pfx = user.iProfile,user.sNick,SetMan.GetString(29):sub(1,1)
if p and n and pfx then
if not Cfg.Exc[n] then if Cfg.Profiles[p] and not Block[n] then Block[n] = true Save() end end
if Core.GetUserValue(user,11) then
local uc,p,cmd = "$UserCommand 1 1 "..Cfg.Menu.."\\"..Cfg.SubMenu.."\\","&#124;|",""
local t = {
{"Toggle User Block","block"," %[line:Nickname (Case Sensitive)]"," %[nick] %[line: Reason (Optional)]"},
{"Check User Block","chkblock"," %[line:Nickname]"," %[nick]"},{"List Blocked Users","listblock","",""},
}
for i,v in ipairs(t) do
cmd = cmd..uc..v[1].."$<%[mynick]> "..pfx..v[2]..v[3]..p..
uc:gsub(" 1 1"," 1 2")..v[1].."$<%[mynick]> "..pfx..v[2]..v[4]..p
end
if cmd ~= "" then Core.SendToUser(user,cmd) end
end
else
return true
end
end
OpConnected,RegConnected = UserConnected,UserConnected

UserDisconnected = function(user)
if Xfer[user.sNick] then if Xfer[user.sNick] >= Cfg.MaxWarn then Xfer[user.sNick] = nil end end
if Search[user.sNick] then if Search[user.sNick] >= Cfg.MaxWarn then Search[user.sNick] = nil end end
end
RegDisconnected, OpDisconnected = UserDisconnected,UserDisconnected

ChatArrival = function(user,data)
if Core.GetUserValue(user,11) then
local _,_,to = data:find("^$To: (%S+) From:")
local _,_,cmd = data:lower():find("%b<> ["..SetMan.GetString(29).."](%a+)")
local _,_,nick = data:find("^%b<> [^ ]+ ([^ |]+)|?")
local _,_,rsn = data:find("^%b<> [^ ]+ [^ ]+ ([^|]+)|$")
if cmd then
if cmd == "block" and nick then
local tab = RegMan.GetReg(nick)
if not tab or not ProfMan.GetProfile(tab.iProfile).tProfilePermissions.bIsOP then
local x,t = Block[nick],{["true"]= "blocked",["false"] = "unblocked"}
if x then x = false else x = true end Block[nick] = x
local s = t[tostring(x)]
if rsn then
local usr = Core.GetUser(nick)
local prof = ProfMan.GetProfile(user.iProfile).sProfileName
if usr then
local msg = "Your search and transfers are being "..s..
" by "..prof.." "..user.sNick.." because:"..rsn.."|"
if Cfg.OnlyPm then
Core.SendPmToUser(usr,Cfg.Bot,msg)
else
Core.SendToUser(usr,"<"..Cfg.Bot.."> "..msg)
end
end
end
Save()
local reply = nick.."'s transfers are now "..s.."|"
if to and to == Cfg.Bot then
Core.SendPmToUser(usr,Cfg.Bot,reply)
else
return Core.SendToUser(user,"<"..Cfg.Bot.."> "..reply),true
end
end
elseif cmd == "chkblock" and nick then
local t = {["true"]= "blocked",["false"] = "unblocked",["nil"] = "not set by script",}
local s = t[tostring(Block[nick])]
local reply = nick.."'s transfers are now "..s.."|"
if to and to == Cfg.Bot then
Core.SendPmToUser(usr,Cfg.Bot,reply)
else
return Core.SendToUser(user,"<"..Cfg.Bot.."> "..reply),true
end
elseif cmd == "listblock" then
local s,t,b,u,x,r = "",{["true"]= "blocked",["false"] = "unblocked"},{},{},0,"¯"
for k,v in pairs(Block) do
if tostring(Block[k]) == "true" then
table.insert(b,k)
else
table.insert(u,k)
end
--s = s.."\n\t"..k.."  is "..t[tostring(Block[k])]
end
if next (b) then
local pl = "s"
if #b == 1 then pl = "" end
s = s.."\n\n\t"..tostring(#b).." Blocked User"..pl..":\n\t"..r:rep(80).."\n"
for i = 1, #b do
if x == 0 then s = s.."\n" end
x = x + 1
if x < 4 then
s = s.."\t"..string.format("%-20.10s\t\t",b[i])
else
x = 0
s = s.."\n"
end
end
end
if next(u) then
local pl = "s"
if #u == 1 then pl = "" end
s = s.."\n\n\t"..tostring(#u).." Unblocked User"..pl..":\n\t"..r:rep(80).."\n"
for i = 1, #u do
if x == 0 then s = s.."\n" end
x = x + 1
if x < 4 then
s = s.."\t"..string.format("%-20.10s\t\t",u[i])
else
x = 0
s = s.."\n"
end
end
end
if s == "" then s = "No results.|" else s = "Listing Users:"..s.."\n\n\t"..r:rep(80).."\n|" end
if to and to == Cfg.Bot then
Core.SendPmToUser(usr,Cfg.Bot,reply)
else
return Core.SendToUser(user,"<"..Cfg.Bot.."> "..s),true
end
end
end
end
end
ToArrival = ChatArrival

ConnectToMeArrival = function(user,data)
local p,n = user.iProfile,user.sNick
local Ctms = {[1] = "^$ConnectToMe ([^ ]-) ",[2] = "^$RevConnectToMe [^ ]- (.+)",}
if Block[n] then
if Cfg.Inc then
for i,v in ipairs(Ctms) do
local _,_,s = data:sub(1,-2):find(v)
if s and s:lower() == Cfg.Inc:lower() then return end
end
end
if Cfg.MaxWarn > 0 then
if Xfer[n] then Xfer[n] = Xfer[n] + 1 else Xfer[n] = 1 end
if Xfer[n] >= Cfg.MaxWarn then
return Core.Kick(user,Cfg.Bot,Cfg.MaxWarn.."x blocked transfer attempts."),true
end
end
local msg = "Your transfers are blocked. Please clear this transfer from your download queue. Thank you.|"
if Cfg.OnlyPm then
return Core.SendPmToUser(user,Cfg.Bot,msg),true
else
return Core.SendToUser(user,"<"..Cfg.Bot.."> "..msg),true
end
end
for i,v in ipairs(Ctms) do
local _,_,s = data:sub(1,-2):find(v)
if s and Block[s] then
local msg1,msg2 = "You requested a file from "..s:format("%q")..", transfers from this user are blocked.|",
"Please clear "..string.format("%q",s).." from your download queue. Thank you.|"
if Cfg.OnlyPm then
return Core.SendPmToUser(user,Cfg.Bot,msg1),
Core.SendPmToUser(user,Cfg.Bot,msg2),true
else
return Core.SendToUser(user,"<"..Cfg.Bot.."> "..msg1),
Core.SendToUser(user,"<"..Cfg.Bot.."> "..msg2),true
end
end
end
end
RevConnectToMeArrival = ConnectToMeArrival

SearchArrival = function (user,data)
local p,n = user.iProfile,user.sNick
if Block[n] then
if Cfg.MaxWarn > 0 then
if Search[n] then Search[n] = Search[n] + 1 else Search[n] = 1 end
if Search[n] >= Cfg.MaxWarn then
return Core.Kick(user,Cfg.Bot,Cfg.MaxWarn.."x blocked search attempts."),true
end
end
local _,_,search = string.find(data,"([^?]+)|$")
if search then
local t = "TTH:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"--hash(t) in lieu of hub(h)
local h,b,i,u = SetMan.GetString(0),SetMan.GetString(21),
SetMan.GetString(3):gsub(";.*",""),SetMan.GetString(4)
local res = "Unknown Path"..string.char(92)..n..", search is "..
"disabled for you :P "..string.rep("\t",15)..search
return Core.SendToUser(user,"$SR "..b.." "..res.." 0 1/2"..t.." ("..i..":"..u..")|"..
"<"..Cfg.Bot.."> "..n..", search is disabled for you. Please close the "..
string.format("%q",search:gsub("%$"," ")).." search window. Thank you.|"),true
end
return true
end
end

SaveFile = function(File,table, tablename )
local hFile = io.open (File , "wb")
assert(hFile)
Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end

Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

Save = function() SaveFile(Cfg.File,Block,"Block") end
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline 4uvak91

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-4
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #50 on: April 05, 2010, 01:27:33 pm »
Tnx for your hard work, but this is not what i'm looking for  :-\. I meant, that unreg user can't use search & download from others in the hub, but OP still can get unreg's filelist! Is there any other script in this forums or do you need to modify OmniBlocker??

Offline Dreams

  • Double Ace
  • *
  • Posts: 114
  • Karma: +1/-12
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #51 on: April 05, 2010, 05:23:14 pm »
that is exactly what this script now does..

-- profile_idx = true/false, [Block transfers, true = yes / false = no]
Profiles = {
   [-1] = true,   --Unregistered User
   
  • = false,   --Master
  • [1] = false,   --Operator
       [2] = false,   --Vip
       [3] = false,   --Registered User
       },
    -- Block Searches from blocked users also?
[false = Search enabled]
NoSearch = true,

And you cant download from blocked users.. thats it, and i dont belive he will mod that for you either.
So i belive you will have to work with what you have pal.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #52 on: April 05, 2010, 11:21:55 pm »
I meant, that unreg user can't use search & download from others in the hub, but OP still can get unreg's filelist!

I already answered this question. Perhaps you need to study the NMDC protocol.
If you allow the op to get the user's file list, that user can then download from the op.
This is the nature of the NMDC protocol. You can't selectively block the transfer between
clients with hubside script.

Then you asked for a mod to AutoBlock for optional search block. OmniBlock was better suited for that mod.
Having modded it for you, you're back to question number one. :P As your logic is circular, read this post in
circular fashion untl it all makes sense. :D
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline 4uvak91

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-4
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #53 on: April 06, 2010, 01:30:36 am »
@dreams I'm asking all this stupid Qs for that reason coz...i have public hub and i don't wanan that some pedos unreg users download/search for pedo files and share it. Thats why I also wanna to check their share, coz it's OP job  :)

@Mutor maybe i don't understand the logic in your script...and I have more important thinks (School subjects) to learn than some NMDC protocol or LUA Scripting. I'm not even scripter or hacker/cracker....so, i don't need these in my future  ;)
« Last Edit: April 06, 2010, 01:34:16 am by 4uvak91 »

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #54 on: April 06, 2010, 02:00:54 am »
What you don't understand is the protocol that is used.
That is why I suggested that you actually read the thing.
I wasn't aware that you are at the extent of your capacity
with your current studies. So if Lua and the protocol is
not important to you than your requests are not
important to me. I work a full week 40 - 60 hours, so
I'm not familiar with the rigors of the half days you spend
at school. Good luck with your Phd.
« Last Edit: April 06, 2010, 04:32:22 am by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline TZB

  • Double Ace
  • *
  • Posts: 149
  • Karma: +13/-0
  • ||-T-z-B-||
    • Gigabyte
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #55 on: April 07, 2010, 09:15:12 pm »
 ;D Moral of the lesson Don't Mess With Mutor :P
Nice work Mutor the update is proving quite handy..
gigahub.no-ip.biz:666

Offline 4uvak91

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-4
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #56 on: April 10, 2010, 11:32:37 pm »
yup yup ;D I use AutoBLock atm instead of OmniBlocker, seems to work fine for me :P

Offline sauron747

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #57 on: May 03, 2011, 07:14:39 pm »
Hello guysl  :)
Actually I want to ask Mutor, because this is his script  8) Is possible to change the script from this line:
Code: [Select]
-- List here a single nick that blocked users may download from. ["Nick" as string or false = disable]
Inc = false,
I need to add more than one nick. Now the script doesn't support several nicks that blocked users may download from specific profile.
Thanks for any solution.       

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #58 on: May 05, 2011, 02:54:42 am »
Why would you need this?
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline sauron747

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
Re: OmniBlocker 1.0 LUA 5.1x [Strict][API 2]
« Reply #59 on: May 06, 2011, 05:35:09 pm »
I want to use this script in relation to master profile (i will block transfers) but i need add more nicks that blocked users may download from specific profile. Actually i want to reverse the blocking transfers. I will block a single Master user (the other profiles will be blocked to download) but i need to add several nicks that blocked user will may to download. The master user provide data files that will be accessible only to VIP and several nicks. If this is not a problem, and not take to much Your time Mutor, please help ;).
Thanks for any solution 

 

determinate determinate