PtokaX forum

Archive => Archived 5.1 boards => Request for scripts => Topic started by: zvamp on 06 October, 2006, 12:53:45

Title: Publichub block-script!
Post by: zvamp on 06 October, 2006, 12:53:45
Hi!!

My hub is in great need of a script that blocks/kicks/timebans users who visit publichubs.
Title: Re: Publichub block-script!
Post by: Psycho_Chihuahua on 06 October, 2006, 12:56:13
search the board - AFAIK such a script already exists
Title: Re: Publichub block-script!
Post by: zvamp on 06 October, 2006, 14:20:38
thanx your wrere right hehe
Posted on: 2006-10-06, 14:23:55
--[[

Anti-Open Hub by Herodes

]]--

tBad = {}
Settings = {
-- Bot Name
sBot = frmHub:GetHubBotName(),
-- How many seconds before disconnecting
iTimeAfter = 15,
}

Main = function()
SetTimer(1000); StartTimer()
end

NewUserConnected = function(user)
if user.iNormalHubs then
if user.iNormalHubs > 0 then
tBad[user.sName] = Settings.iTimeAfter
user:SendData( "Helvetia", "You are in public hubs which is violating against our hubrules. "..
"This is why your connection will be terminated in "..Settings.iTimeAfter.." seconds!!!")
end
end
end

OnTimer = function()
for i,v in ipairs(frmHub:GetOnlineNonOperators()) do
if v.iNormalHubs and v.iNormalHubs > 0 and not tBad[v.sName] then tBad[v.sName] = Settings.iTimeAfter end
end
for nick,v in pairs(tBad) do
local user = GetItemByName(nick)
if user.iNormalHubs then
if user.iNormalHubs == 0 then
tBad[nick] = nil
user:SendData(Settings.sBot, "Thank you for closing the public hubs and are now following "..
"our rules.")
elseif user.iNormalHubs > 0 then
tBad[nick] = tBad[nick] - 1
if tBad[nick] == 0 then
tBad[nick] = nil
user:SendData(Settings.sBot,"Your connection was terminated because you were in public hubs. "..
"Feel free to return once you have closed your public hub connections.")
user:Disconnect()
elseif tBad[nick] == math.floor(Settings.iTimeAfter/2) then
user:SendData (Settings.sBot," Please don't hang around in public "..
"File-Sharing-Platforms. This is dangerous for you and for us. You still have "..
math.floor(Settings.iTimeAfter/2).." seconds left until your connection is terminated..")
end
end
end
end
end

UserDisconnected = function(user)
if tBad[user.sName] then tBad[user.sName] = nil; collectgarbage(); end
end


I like this script very much!! but I need the script to timeban user 1h =)
Title: Re: Publichub block-script!
Post by: Stormbringer on 06 October, 2006, 14:28:41
QuoteMy hub is in great need of a script that blocks/kicks/timebans users who visit publichubs.

And for which valid reasons please?
I'm interested by your answer


Title: Re: Publichub block-script!
Post by: zvamp on 06 October, 2006, 14:34:35
hubrules
Title: ...
Post by: Stormbringer on 06 October, 2006, 21:14:52
LOL. Excellent rules.
I guess the public hub are possessed by the demon...



Title: Re: Publichub block-script!
Post by: zvamp on 07 October, 2006, 12:09:35
yep
Title: Re: Publichub block-script!
Post by: Herodes on 07 October, 2006, 14:31:29
I have just tested that this can be loaded in PtokaX,..

pls test and post some feedback,.. not tested in action!

--- Anti-Open Hub v2
--- by Herodes

tBad = {}
tSettings = {
-- Bot Name
sBot = frmHub:GetHubBotName(),
-- OpChat Name or Name that the operators ar going to be notified from.
sOpChat = frmHub:GetOpChatName(),
-- How many seconds before disco/tban/pban the user?
iTimeAfter = 15,
-- Notify the operators?
bNotifyOps = true,
-- What should we do? ::  0:nothing / 1:disconnect / 2:permban / whatever other number is the minutes to tempban the guy.
iAction = 1,
-- If iActions is set to tban the user. Then this says for how many minutes.
iTempBanTime = 60
}

function Main()
SetTimer(1000);
StartTimer()
end

function NewUserConnected( user )
if user.iNormalHubs and user.iNormalHubs > 0 then
tBad[user.sName] = tSettings.iTimeAfter
user:SendData( "Helvetia", "You are in public hubs which is violating against our hubrules. This is why you are going to be disconnected in "..Settings.iTimeAfter.." seconds!!!")
SendPmToOps( tSettings.sOpChat, user.sName.." - ["..user.sIP.."] on "..os.date("%x %X").." entered with ".. user.iNormalHubs.." public hubs in the tag." )
end
end

function OnTimer()
for i,v in ipairs(frmHub:GetOnlineNonOperators()) do
if v.iNormalHubs and v.iNormalHubs > 0 and not tBad[v.sName] then
tBad[v.sName] = tSettings.iTimeAfter
end
end
for nick,v in pairs(tBad) do
local user = GetItemByName(nick)
if user.iNormalHubs then
if user.iNormalHubs == 0 then
table.remove(tBad, nick)
user:SendData(tSettings.sBot, "Thank you for closing the public hubs and are now following our rules.")
else
tBad[nick] = tBad[nick] - 1
if tBad[nick] == 0 then
table.remove( tBad, nick )
if tSettings.iAction == 1 then
user:SendData(tSettings.sBot,"Your connection was terminated because you were in public hubs. Feel free to return once you have closed your public hub connections.")
user:Disconnect()
elseif tSettings.iAction == 2 then
user:SendData( tSettings.sBot, "You haven't realised we where talking bussiness with the number of public hubs. So off you go,... permantely Banned!")
user:Ban("Public Hubs Disobidience", tSettings.sBot, true)
elseif tSettings.iAction > 2 then
user:SendData( tSettings.sBot, "You haven't realised we where talking bussiness with the number of public hubs. So off you go,... temporalily Banned!")
user:TempBan(tSettings.iTempBanTime, "Public Hubs Disobidience", tSettings.sBot, true)
end
elseif tBad[nick] == math.floor(tSettings.iTimeAfter/2) then
user:SendData(tSettings.sBot," Please don't hang around in public File-Sharing-Platforms. This is dangerous for you and for us. You still have "..
math.floor(tSettings.iTimeAfter/2).." seconds left until your connection is terminated..")
end
end
end
end
end

UserDisconnected = function(user)
if tBad[user.sName] then
table.remove(tBad, user.sName)
collectgarbage();
end
end
Title: Re: Publichub block-script!
Post by: zvamp on 07 October, 2006, 16:51:15
\scripts\Anti-Open-Hub-v2.lua:28: attempt to index global 'Settings' (a nil value)
\scripts\Anti-Open-Hub-v2.lua:48: bad argument #2 to 'remove' (number expected, got string)
\scripts\Anti-Open-Hub-v2.lua:41: attempt to index local 'user' (a nil value)

The script does not disconnect/timeban, it just says :Please don't hang around in public File-Sharing-Platforms. This is dangerous for you and for us. You still have 7 seconds left until your connection is terminated..

and nothing else happens..

Title: Re: Publichub block-script!
Post by: Psycho_Chihuahua on 07 October, 2006, 17:14:52
\scripts\Anti-Open-Hub-v2.lua:28: attempt to index global 'Settings' (a nil value)

is easy to fix
change "..Settings.iTimeAfter.." to "..tSettings.iTimeAfter.."


as for the other, i haven't found the problem
\scripts\aoh.lua:48: bad argument #2 to 'remove' (number expected, got string)

but check that you are using a Lua 5.1 version of ptokax
Title: Re: Publichub block-script!
Post by: zvamp on 07 October, 2006, 23:06:13
thanks Psycho_Chihuahua =) yes I`m using lua 5.1

but still this error: \Anti-Open-Hub-v2.lua:48: bad argument #2 to 'remove' (number expected, got string)

Does not kick/timeban..

Title: Re: Publichub block-script!
Post by: Psycho_Chihuahua on 07 October, 2006, 23:12:05
Quote from: Psycho_Chihuahua on 07 October, 2006, 17:14:52
as for the other, i haven't found the problem
\scripts\aoh.lua:48: bad argument #2 to 'remove' (number expected, got string)

like i mentioned before, i haven't figured that one out yet :(
Title: Re: Publichub block-script!
Post by: Herodes on 08 October, 2006, 22:45:21
Quote from: Psycho_Chihuahua on 07 October, 2006, 23:12:05
like i mentioned before, i haven't figured that one out yet :(
yep that one is my bad...
I'll explain,...


tTable = { [1] = "ok", ["not"] = "ok" }

table.remove( tTable, 1 ) -- this is equal
tTable[1] = nil; -- to this...
-- but tTable["not"] can't be removed unless you do this :
tTable["not"] = nil;
-- the following will not work..
table.remove( tTable, "not" )

I hope this clears it up...
here is the script.. again not tested

--- Anti-Open Hub v2
--- by Herodes

tBad = {}
tSettings = {
-- Bot Name
sBot = frmHub:GetHubBotName(),
-- OpChat Name or Name that the operators ar going to be notified from.
sOpChat = frmHub:GetOpChatName(),
-- How many seconds before disco/tban/pban the user?
iTimeAfter = 15,
-- Notify the operators?
bNotifyOps = true,
-- What should we do? ::  0:nothing / 1:disconnect / 2:permban / whatever other number is the minutes to tempban the guy.
iAction = 1,
-- If iActions is set to tban the user. Then this says for how many minutes.
iTempBanTime = 60
}

function Main()
SetTimer(1000);
StartTimer()
end

function NewUserConnected( user )
if user.iNormalHubs and user.iNormalHubs > 0 then
tBad[user.sName] = tSettings.iTimeAfter
user:SendData( tSettings.sBot, "You are in public hubs which is violating against our hubrules. This is why you are going to be disconnected in "..tSettings.iTimeAfter.." seconds!!!")
SendPmToOps( tSettings.sOpChat, user.sName.." - ["..user.sIP.."] on "..os.date("%x %X").." entered with ".. user.iNormalHubs.." public hubs in the tag." )
end
end

function OnTimer()
for i,v in ipairs(frmHub:GetOnlineNonOperators()) do
if v.iNormalHubs and v.iNormalHubs > 0 and not tBad[v.sName] then
tBad[v.sName] = tSettings.iTimeAfter
end
end
for nick,v in pairs(tBad) do
local user = GetItemByName(nick)
if user.iNormalHubs then
if user.iNormalHubs == 0 then
table.remove(tBad, nick)
user:SendData(tSettings.sBot, "Thank you for closing the public hubs and are now following our rules.")
else
tBad[nick] = tBad[nick] - 1
if tBad[nick] == 0 then
tBad[nick] = nil;
if tSettings.iAction == 1 then
user:SendData(tSettings.sBot,"Your connection was terminated because you were in public hubs. Feel free to return once you have closed your public hub connections.")
user:Disconnect()
elseif tSettings.iAction == 2 then
user:SendData( tSettings.sBot, "You haven't realised we where talking bussiness with the number of public hubs. So off you go,... permantely Banned!")
user:Ban("Public Hubs Disobidience", tSettings.sBot)
elseif tSettings.iAction > 2 then
user:SendData( tSettings.sBot, "You haven't realised we where talking bussiness with the number of public hubs. So off you go,... temporalily Banned!")
user:TempBan( tSettings.iTempBanTime, "Public Hubs Disobidience", tSettings.sBot)
end
elseif tBad[nick] == math.floor(tSettings.iTimeAfter/2) then
user:SendData(tSettings.sBot," Please don't hang around in public File-Sharing-Platforms. This is dangerous for you and for us. You still have "..tBad[nick].." seconds left until your connection is terminated..")
end
end
end
end
end

function UserDisconnected( user )
if tBad[user.sName] then
tBad[user.sName] = nil;
collectgarbage();
end
end
Title: Re: Publichub block-script!
Post by: zvamp on 08 October, 2006, 23:19:00
\scripts\Anti-Open-Hub-v2.lua:43: bad argument #2 to 'remove' (number expected, got string)

"You haven't realised we where talking bussiness with the number of public hubs. So off you go,... temporalily Banned!"

The script does not timeban =(
thanx for helping us out:)
Title: Re: Publichub block-script!
Post by: Herodes on 09 October, 2006, 08:54:26
Script edited once again,... could you pls grab it again?

okie here is the catch
user:TempBan()
user:TempBan(iTime, sReason, sBy, bFull)    -- iTime is in minutes (0 = default tempban time from gui) !

user:Ban()
user:Ban(sReason, sBy, bFull)

I don't really know what the bFull function argument is doing.
So I just took it off in the script.
Title: Re: Publichub block-script!
Post by: zvamp on 09 October, 2006, 16:51:33
Disconnect works fine.. No errors, but still it will not tempban & permban..

this is the script version I use now. I put iAction = 60, is this right??

--- Anti-Open Hub v2
--- by Herodes

tBad = {}
tSettings = {
-- Bot Name
sBot = frmHub:GetHubBotName(),
-- OpChat Name or Name that the operators ar going to be notified from.
sOpChat = frmHub:GetOpChatName(),
-- How many seconds before disco/tban/pban the user?
iTimeAfter = 15,
-- Notify the operators?
bNotifyOps = true,
-- What should we do? ::  0:nothing / 1:disconnect / 2:permban / whatever other number is the minutes to tempban the guy.
iAction = 60,
-- If iActions is set to tban the user. Then this says for how many minutes.
iTempBanTime = 60
}

function Main()
SetTimer(1000);
StartTimer()
end

function NewUserConnected( user )
if user.iNormalHubs and user.iNormalHubs > 0 then
tBad[user.sName] = tSettings.iTimeAfter
user:SendData( tSettings.sBot, "You are in public hubs which is violating against our hubrules. This is why you are going to be disconnected in "..tSettings.iTimeAfter.." seconds!!!")
SendPmToOps( tSettings.sOpChat, user.sName.." - ["..user.sIP.."] on "..os.date("%x %X").." entered with ".. user.iNormalHubs.." public hubs in the tag." )
end
end

function OnTimer()
for i,v in ipairs(frmHub:GetOnlineNonOperators()) do
if v.iNormalHubs and v.iNormalHubs > 0 and not tBad[v.sName] then
tBad[v.sName] = tSettings.iTimeAfter
end
end
for nick,v in pairs(tBad) do
local user = GetItemByName(nick)
if user.iNormalHubs then
if user.iNormalHubs == 0 then
table.remove(tBad, nick)
user:SendData(tSettings.sBot, "Thank you for closing the public hubs and are now following our rules.")
else
tBad[nick] = tBad[nick] - 1
if tBad[nick] == 0 then
tBad[nick] = nil;
if tSettings.iAction == 1 then
user:SendData(tSettings.sBot,"Your connection was terminated because you were in public hubs. Feel free to return once you have closed your public hub connections.")
user:Disconnect()
elseif tSettings.iAction == 2 then
user:SendData( tSettings.sBot, "You haven't realised we where talking bussiness with the number of public hubs. So off you go,... permantely Banned!")
user:Ban("Public Hubs Disobidience", tSettings.sBot)
elseif tSettings.iAction > 2 then
user:SendData( tSettings.sBot, "You haven't realised we where talking bussiness with the number of public hubs. So off you go,... temporalily Banned!")
user:TempBan( tSettings.iTempBanTime, "Public Hubs Disobidience", tSettings.sBot)
end
elseif tBad[nick] == math.floor(tSettings.iTimeAfter/2) then
user:SendData(tSettings.sBot," Please don't hang around in public File-Sharing-Platforms. This is dangerous for you and for us. You still have "..tBad[nick].." seconds left until your connection is terminated..")
end
end
end
end
end

function UserDisconnected( user )
if tBad[user.sName] then
tBad[user.sName] = nil;
collectgarbage();
end
end
Title: Re: Publichub block-script!
Post by: bastya_elvtars on 10 October, 2006, 00:16:37
Quote from: Stormbringer on 06 October, 2006, 21:14:52
LOL. Excellent rules.
I guess the public hub are possessed by the demon...

:)
Title: Re: Publichub block-script!
Post by: BrotherBear on 25 October, 2006, 22:50:36
Hi!

I have changed a little bit in Mutor's Script and hope that I am doing this right now :)

Have I done something wrong with posting it like this then say so.


--[[
NoPubHub 1.1 LUA 5.0/5.1

By Mutor 07/18/06
Minor changes By BrotherBear 10/25/06

Requested by WingZero

Send PM to OpChat about users who are in public hubs and the OP's can decide what to do :)

- Check / Exclude by profile [set Exclude table ~line 22]
- Checks in MyINFOArrival to detect public connections made after login
]]
tSettings = {
-- OpChat Name or Name that the operators ar going to be notified from.
sOpChat = frmHub:GetOpChatName(),
}

MyINFOArrival = function(user,data)
--Exclude check by profile
--[#] = {0=check/1=exclude, "Profile Name"},
local Exclude = {
[-1] = {1,"Unregistered User"},
[0] = {0,"Master"},
[1] = {1,"Operator"},
[2] = {0,"Vip"},
[3] = {0,"Registered User"},
[4] = {0,"Moderator"},
[5] = {1,"NetFounder"},
}
if not Exclude[user.iprofile] or Exclude[user.iprofile][1] ~= 1 then
if user.iNormalHubs ~= 0 then
SendPmToOps( tSettings.sOpChat, "User: "..user.sName.." with IP: "..user.sIP.." and Tag "..user.sTag.." was detected in ".. user.iNormalHubs.." public hub(s) at "..os.date("%x %X") )
return 1
end
end
end


Hope you enjoy it :)
Title: Re: Publichub block-script!
Post by: zvamp on 07 November, 2006, 13:32:50
Nice BrotherBear and Mutor =) but there is an error with Mutors version when a user logs in with publichubs:

lua:31: attempt to index field '?' (a nil value)
Title: Re: Publichub block-script!
Post by: Thor on 07 November, 2006, 16:01:32
Change
Code (lua) Select

if not Exclude[user.iprofile] or Exclude[user.iprofile][1] ~= 1 then
if user.iNormalHubs ~= 0 then
local  Profile = Exclude[user.iprofile][2] or "Unknown Profile"

To:
Code (lua) Select

if not Exclude[user.iProfile] or Exclude[user.iProfile][1] ~= 1 then
if user.iNormalHubs ~= 0 then
local  Profile = Exclude[user.iProfile][2] or "Unknown Profile"
Title: Re: Publichub block-script!
Post by: zvamp on 10 November, 2006, 13:37:15
thx =)
Title: Re: Publichub block-script!
Post by: Grax on 24 February, 2007, 15:06:20
Sorry my english is very bad.
here a new version
--[[
NoPubHub 1.1 LUA 5.0/5.1

By Mutor 07/18/06
Minor changes By BrotherBear 10/25/06

Requested by WingZero

Send PM to OpChat about users who are in public hubs and the OP's can decide what to do :)

- Check / Exclude by profile [set Exclude table ~line 22]
- Checks in MyINFOArrival to detect public connections made after login
- Timer function and disconnect (added by Grax & Pulsar 24.07.2007)
]]

tBadOnes = {}
iTimeAfter = 60 -- how many seconds before disconnecting

function Main()
SetTimer( 1000 )
StartTimer()
end

MyINFOArrival = function(user,data)
-- OpChat Name or Name that the operators ar going to be notified from.
local sBot = frmHub:GetHubBotName()
--Exclude check by profile
--[#] = {0=check/1=exclude, "Profile Name"},
local Exclude = {
[-1] = {0,"Unregistered User"},
[0] = {1,"Master"},
[1] = {0,"Operator"},
[2] = {0,"Vip"},
[3] = {0,"Registered User"},
[4] = {1,"Moderator"},
[5] = {1,"NetFounder"},
}

if not Exclude[user.iProfile] or Exclude[user.iProfile][1] ~= 1 then
if user.iNormalHubs ~= 0 then
tBadOnes[user.sName] = iTimeAfter
user:SendData(sBot, "Du bist in "..user.iNormalHubs.." Open Hubs. Verbindung wird in "..iTimeAfter.." Sekunden zur?ckgesetzt!")
local  Profile = Exclude[user.iProfile][2] or "Unknown Profile"
return SendPmToOps(sBot, "\r\n\r\n\tUser : "..user.sName..
"\r\n\tProfil : "..Profile.."\r\n\tIP : "..user.sIP..
"\r\n\tTag : "..user.sTag.."\r\n\r\n\t wurde am "..os.date("%x %X").." in "
..user.iNormalHubs.." Public Hub(s) erwischt!" )

end
end
end

function OnTimer()
for nick, v in pairs(tBadOnes) do
local user = GetItemByName( nick )
if user.iNormalHubs then
if user.iNormalHubs == 0 then
tBadOnes[nick] = nil
user:SendData(sBot, "Danke, daf?r dass du die Open Hubs geschlossen hast und nun ganz Regelkonform mitmachst." )
elseif user.iNormalHubs > 0 then
tBadOnes[nick] = tBadOnes[nick] - 1
if tBadOnes[nick] == 0 then
tBadOnes[nick] = nil
user:SendData(sBot, "Du wirst jetzt Disconnected weil du in Open Hubs rumlungerst. Komm bitte erst wieder wenn du sie geschlossen hast." )
user:Disconnect()
elseif tBadOnes[nick] == math.floor( iTimeAfter / 2 ) then
user:SendData (sBot, " Wir bitten euch inst?ndig nicht in den offenen File-Sharing-Plattformen zu bewegen. Das ist n?mlich auch f?r uns gef?hrlich. Du hast noch "..math.floor( iTimeAfter / 2 ).." Sekunden ?brig bis zur Trennung..." )
end
end
end
end
end
Title: Re: Publichub block-script!
Post by: BrotherBear on 24 February, 2007, 22:30:40
Quote from: Stormbringer on 06 October, 2006, 14:28:41
And for which valid reasons please?
I'm interested by your answer

Why are you people always asking about this?

We have a rule that say that the users can not be on Public hubs
when they are in our Hub.

We have a reason why we does this and please respect this.

The users has all right to be on Public hubs, but not when they are
in Our Private hub.

We are doing this to let the users who are in our hub feel that
they are a little more secure against APB in our case.
Title: Re: Publichub block-script!
Post by: Stormbringer on 24 February, 2007, 23:48:08
QuoteWe are doing this to let the users who are in our hub feel that
they are a little more secure against APB in our case.

lol that was funny, if you told them that it's more safe for them, just stop to lie to them, if they believe what you say they are ignorant, or don't know what is p2p/dc.
It's your hub, you create the rules that you want (I was ban one time from a hub when I had written my nick in uppercase lol, so you see you are not alone to create weird rules lol), but please let me comment this strange choice, it's my right too.
Title: Re: Publichub block-script!
Post by: bastya_elvtars on 25 February, 2007, 03:38:31
Secure? Unplug the cable, plzkthx