PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: x0cHiPiLLi on 21 January, 2004, 03:59:12

Title: Please need help for passing thrue the stupidy of profitt! help me ple
Post by: x0cHiPiLLi on 21 January, 2004, 03:59:12
Hi! Greeting to you all, you've helpme a lot!
But i need your help!

I live in Portugal, and in here the adsl connection is limited to 2gb (international) and 20gb(national) traffic! What happens is that there is a lot of "portugueese-only" hubs by checking the IP range of the connections!
I used an IP Table (very simple one)!

But i want to make my hub national and international at the same for registers users!

My Ideia was that every user could connect to the hub but not download from it until it was regged by an op! (THIS PART IS DONE)

So, when international users wanna connect to the hub their are forced to attribute a prefix to their nick like "_"! so then the hub and the users knows whos "International" or not!

So what I need?

I need a bot to make a table of "international" users, those who's prefix is "", and then this bot by commands like:

!international : allows the current national user to download files from international users

!national : blocks the current national user from downloading from international users

Please help me! and us Portuguese, it would make a big diference, for the global comunity as all! many thx

PS: if ups could be controlled it would be nice too (but not needed)!

THanX a LoT!
Peace, Love, Unity & Respect
Title: leechblocker
Post by: [SWE]henrik on 21 January, 2004, 05:17:31
im not sure if i understand you but this is a script that block unregged users from downloading, then if you like to demand users to use prefix to be able to download is something that you have to deside...
this is the first time i post a script, hope it works

code:
---------------------------------------------------
---------------------

-- LEECHBLOCKER 02 -- for PtokaX TD4

---------------------

-- Created by SAMPLERman - HUB: samplerman.no-ip.info

-- 5/August/2003

-- Based on an idea by OpiumVolage and RabidWombat

-- And thanks AGAIN to RabidWombat for new ideas



-- This LUA script prevents users that are not registered in the hub (=aliens)

-- from connecting to other users (for downloading).

-- New users (=aliens) can chat, upload and be searched. They just can't download.



-- This way your previously private hub can again be public.



-- Optionally, the script also blocks searches (from nonregged users).

-- However, it is recommended that you allow everyone to search your hub, so that

-- new users know what they are missing.



-- NEW in version 02:

-- To allow an alien to download for 1 session, OPs can type this command:

-- !letleech



-- To do for next version:

-- Optionally, aliens can download off of other aliens



-- There are 2 kinds of hubs:

-- 1) Open hubs for sharing anything

-- 2) Small hubs that concentrate on a special interest (e.g. classical sheet music)



-- This script is NOT recommended for hub kind #1, where it is enough to

-- control how many GB users are sharing.

-- Because in hub type #1 there is no point in registering users, this script

-- should be adapted to make shared amount the criteria for letting download.

-- Even better, for hub type #1 users who share little should be allowed to download

-- from other people who share little.

-- Freedom is a strength of the Direct Connect community; please do not cut into

-- people's freedom except when absolutely necessary.

-- This script is only for closed hubs with a very specific subject.



-------------------------------

-- SOURCES OF SCRIPTING INFO --

-------------------------------

-- Scripting.txt (comes with PtokaX)

--

-- LUA reference manual 4.0.pdf



----------------------

-- GLOBAL VARIABLES -- make changes here only

----------------------

smDebugging = "0" -- Default is "0" (silent mode). "1" sends msgs to OPs

smBlockSearches = "0" -- Default is "0" (do not block searches)

smBlockSearchExceptions = { "scores", "sheet music" }



MsgToAliens = " \r\n\t"..
"\t\t\t<<<<<<  WARNING  >>>>>>\r\n\t"..
"\r\n\t"..
"\t\tYOU ARE UNABLE TO DOWNLOAD IN THIS HUB\r\n\t"..
"\t\t-------------------------------------------------------------------------------------\r\n\t"..
"\t\tOnly registered users can see fileslists and download.\r\n\t"..

"\t\t\tYou can only Chat ...\r\n\t"..

"\t\tPlease, register your nickname in Joki-Box II Acoustic Lovers\r\n\t"..

"\t\t 1)  type in main chat this command ------>  !rules\r\n\t"..
"\t\t 2)  Ask to  Operators.\r\n\t"..
"\t\t-------------------------------------------------------------------------------------\r\n\t"..

"\t\t\tWe hope you will join us .\r\n\t"




LetLeechCommand = "!permit"



----------------------------------

-- Do not change anything below --

----------------------------------

smBot = frmHub:GetHubBotName() -- This line gets bot name from PtokaX hubsoftware;

-- therefore, your Hub Bot should be enabled.



ToBlock = { "^$ConnectToMe%s(%S+)", "^$RevConnectToMe%s(%S+)", "^$Search%s+(%S+)"}

LetLeech = {}



--// This function is called when hub or script starts

function Main()

frmHub:EnableFullData(1)

frmHub:UnregBot(smBot)

frmHub:RegBot(smBot)

--// If thus configured, remove search from blocking table:

if smBlockSearches == "0" then

for i,v in ToBlock do

if v == "^$Search%s+(%S+)" then ToBlock = nil end

end

end

end



--// This function is fired when a new user (non-OP) finishes login

function NewUserConnected(user)

if user.iProfile == -1 then

user:SendData(smBot,"\r\n"..MsgToAliens)

end

end



--// This function is fired when new data arrives

function DataArrival (user, data)



--// See if data is the !letleech command:

if strsub(data, 1, 1) == "<" then

local line=strsub(data,1,strlen(data)-1) -- remove last char

local s,e,cmd = strfind(line, "%b<>%s+(%S+)")

local s,e,arg = strfind(line, "%b<>%s+%S+%s+(%S+)")

if strlower(cmd)==strlower(LetLeechCommand) then

if user.iProfile ~= 0 and user.iProfile ~= 1 then

SendToAll(smBot, "...but you are not an OP!")

return nil

end

who = GetItemByName(arg)

if not who then

SendToOps(smBot, arg.." is not online.")

return 1

end

if who.iProfile ~= -1 then

SendToOps(smBot, arg.." is registered and does not need a leech license.")

return 1

end

LetLeech[arg] = 1

SendToOps(smBot,arg.." is now authorized to download for this session.")

who:SendData(smBot,arg..", you are now authorized to download for this session.")

return 1

end

end



--// See if data should be blocked:

for _,blockstring in ToBlock do

local _, _, who = strfind(data, blockstring)

if who then return smBlock(user,data,who) end

end

end



function smBlock(user,data,who)

local report

local profnam = GetProfileName(user.iProfile)

if profnam then

profnam = strlower(profnam)

else

profnam = "alien"

end

--// Activity by Masters, OPs, VIPs and REGs are just reported to OPs:

--// Also, searches pass if they are in the exception list:

--// Data also passes if user is in LetLeech list:

if (user.iProfile ~= -1) or smMatchException(data)

or IsInLeechList(user) then

report = "\t"..user.sName.." ("..profnam..") sends:\r\n\t"..data

smDebugToOPs(report)

return nil

end

--// Alien (not registered) users get blocked:

local report = "\tBlocked from "..user.sName.." ("..

profnam.."):\r\n\t"..data

smDebugToOPs(report)

return 1

end



function smMatchException(data)

if strfind (data, "^$Search%s+(%S+)") then

for _,exceptword in smBlockSearchExceptions do

if strfind (strlower(data), strlower(exceptword)) then

return 1

end

end

end

return nil

end



function IsInLeechList(user)

for i,v in LetLeech do

if i == user.sName then return 1 end

end

return nil

end



function smDebugToOPs(data)

if smDebugging == "1" then

SendToOps(smBot,data)

end

end
Title:
Post by: ????L?F?? on 21 January, 2004, 10:16:20
humm, i dont think you can tel if its internation or not by the tag, people can fake it you know ^^

and im not following exactly when you want aswel
Title: it's not that
Post by: x0cHiPiLLi on 21 January, 2004, 17:40:45
I need the other way around!

I need to enable/unable ppl regged in the hub to only download from a certain prefix when they want!

Don't worry about detecting "international" by the prefix! the away that is working its almost impossible to "fake"!

So what a need! is a kind of leechblocker but the other way around, in leechblocker you can prevent users with a certain prefix ou regged ones to download from the hub!
I need the other way around! not to upload to users without the prefix (unless they want)!

Like this:

You have 4 users:

"xxx"
"xpto"
"yyy"
"zzz"


If user "zzz" makes "!international" it will be able to download from xxx and xpto when he permits it (like when zzz makes in his dc "!international")!

leechblocker is the other away around!

Don't worry that the prefix could be faked! I'll handle that!

Many thx for your answer, but it's not the suited one!
If you could help me ....

PLUR
Title: The ideia behind this is...
Post by: x0cHiPiLLi on 21 January, 2004, 17:54:09
The ideia behind this is...

To make an international hub, for only regs and by the prefix, allow users without prefix do download from them when only they want!

In here (Portugal), regular ADSL download limit is:

2 Gb(Internacional) (users that would be with a prefix !
20Gb(Nacional) (users that would not have a prefix)

This would allow National users to stay on this international hub, but with the possibility of controlling their traffic limits!

Many Thx!