[Q?]slot,share,client check
 

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

[Q?]slot,share,client check

Started by Snooze, 11 June, 2004, 03:42:10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Snooze

I were just wondering what the fastes way to check for:

Minshare
Maxshare
Minslot
Maxslot
etc

Right now I'm doing it from the "NewUserConnected" witch seems really fast, though users still gets in long enough to get the MOTD and UserList ??
How can i avoid that ?

Well... any help would be really great ..


**Snooze

bastya_elvtars

IMHO its better they get motd and userlist... they can decide whether they wanna enter @ all  :D
Everything could have been anything else and it would have just as much meaning.

tezlo

best check every time a new $MyINFO comes

Herodes

Carefull!!
This one dont work ! ! !

function DataArrival(user, data)
if strsub(data, 1, 7) == "$MyINFO" then
	data = strsub(data, 1, (strlen(data)-1))
	local s,e,description,tag,_,_, share = strfind(data, "^%$MyINFO $ALL %S+%s+(.*)<([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
	SendData(bot, tag)
	slots = strfind(tag, "S:%d+>")
	ushare = strfind(data "$(%d+)%$")
	SendData(bot, "Slots: "..slots)
	SendData(bot, "Share:"..ushare)
end
end

I was playing with this earlier ...
but I need to get a whole lot better with my string operations ...

Not now anyhow ,,,
going to sleep first ..  

I just thought " What a coincidence ... "  nn all .. :D

Snooze

QuoteIMHO its better they get motd and userlist... they can decide whether they wanna enter @ all
Well.. they better be really fast readers ;) - they get to hang in the hub for less than ? a sec.

So.. Is it that much faster to get it from dataarrival ?


**Snooze

tezlo

#5
it's not any faster but rather obvious to check whenever it changes
NewUserConnected gets called right after the first $MyINFO is received

Snooze

This is my current hub/slot check - if you can see anywhere I can uptimize it, please let me know.


function DataArrival(user,data)
               hubsc = 0
		if ( strsub(data, 1, 12) == "$MyINFO $ALL" ) then
		if not (user.bOperator) or (GetProfileName(user.iProfile) == "VIP" or (GetProfileName(user.iProfile) == "Special")) then
              		 s,e,thubs,slots = strfind(data,  "H:([%d%/]+),S:(%d+)%S*>")
				if thubs==nil or slots==nil then
					user:SendData(Bot, "Your Client did not respond with proper tag!! - Latest allowed clients can be found here: [URL]http://www.snooze.no-ip.com/sk/viewforum.php?f=25[/URL]")
					user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
					SKHUBSTAT["hBadClient"] = SKHUBSTAT["hBadClient"] + 1
					SaveSKHUBSTAT()
						if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Bad Client tag. "..user.sMyInfoString) end
					return 1
				end
             				if tonumber(thubs) == nil then
                 				gsub(thubs, "(%d+)", function (num)
                     				hubsc = hubsc +tonumber(num)
                 			end)
               				else
                  				hubsc = tonumber(thubs)
              				end
               			slots = tonumber(slots)
			if slots < (tonumber(SKCONF["sHSRatio"])*hubsc) then
				user:SendData(Bot, "Your are in violation with this hubs Hub/Slot Ratio: '"..tonumber(SKCONF["sHSRatio"]).." Slot per Hub'")
				user:SendData("$ForceMove "..arg)
				SKHUBSTAT["hSlotRatio"] = SKHUBSTAT["hSlotRatio"] + 1
				SaveSKHUBSTAT() --// Hub/Slot Ratio
				return 1
			elseif (hubsc > tonumber(SKCONF["sMaxHubs"])) and (tonumber(SKCONF["sMaxHubs"]) > 0) then
				user:SendData(Bot, "Your are in violation with this hubs Max Hub Rule: Max "..tonumber(SKCONF["sMaxHubs"]).." Hubs.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				SKHUBSTAT["hMaxhubs"] = SKHUBSTAT["hMaxhubs"] + 1
				SaveSKHUBSTAT() --// Max Hubs
			elseif ((slots < tonumber(SKCONF["sMinSlots"])) or (slots > tonumber(SKCONF["sMaxSlots"]))) and (tonumber(SKCONF["sMinSlots"]) > 0) then
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:SendData(Bot, "Your are in violation with this hubs Slots Rule: Min "..tonumber(SKCONF["sMinSlots"]).." Slots. - Max "..tonumber(SKCONF["sMaxSlots"]).." Slots.")
				SKHUBSTAT["hMinslots"] = SKHUBSTAT["hMinslots"] + 1
				SaveSKHUBSTAT() --// Min/Max Slots
				return 1
			end
		end
	end

There gotta be a faster way to do ... I see doing it alot faster ..

Well... any suggestions are more than welcome :)

**Snooze

Snooze

This solved it ..

function DataArrival(user,data)
	----------------------------------------DataArrival-------------------------------------------
	----------------------------------- Rules Check START (hub/slots)--------------------------------
               hubsc = 0
		if ( strsub(data, 1, 12) == "$MyINFO $ALL" ) then
		if not (user.bOperator) or (GetProfileName(user.iProfile) == "VIP" or (GetProfileName(user.iProfile) == "Special")) then
              		 s,e,thubs,slots = strfind(data,  "H:([%d%/]+),S:(%d+)%S*>")
				if thubs==nil or slots==nil then
					user:SendData(Bot, "Your Client did not respond with proper tag!! - Latest allowed clients can be found here: [URL]http://www.snooze.no-ip.com/sk/viewforum.php?f=25[/URL]")
					user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
					SKHUBSTAT["hBadClient"] = SKHUBSTAT["hBadClient"] + 1
					SaveSKHUBSTAT()
						if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Bad Client tag - ("..data..")") end
					return
				end
             				if tonumber(thubs) == nil then
                 				gsub(thubs, "(%d+)", function (num)
                     				hubsc = hubsc +tonumber(num)
                 			end)
               				else
                  				hubsc = tonumber(thubs)
              				end
               			slots = tonumber(slots)
			if slots < (tonumber(SKCONF["sHSRatio"])*hubsc) then
				user:SendData(Bot, "Your are in violation with this hubs Hub/Slot Ratio: '"..tonumber(SKCONF["sHSRatio"]).." Slot per Hub'")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hSlotRatio"] = SKHUBSTAT["hSlotRatio"] + 1
				SaveSKHUBSTAT() --// Hub/Slot Ratio
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Ratio - ("..(tonumber(SKCONF["sHSRatio"])*hubsc)..")") end
				return 1
			elseif (hubsc > tonumber(SKCONF["sMaxHubs"])) and (tonumber(SKCONF["sMaxHubs"]) > 0) then
				user:SendData(Bot, "Your are in violation with this hubs Max Hub Rule: Max "..tonumber(SKCONF["sMaxHubs"]).." Hubs.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hMaxhubs"] = SKHUBSTAT["hMaxhubs"] + 1
				SaveSKHUBSTAT() --// Max Hubs
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Max Hubs - ("..hubsc..")") end
				return 1
			elseif ((slots < tonumber(SKCONF["sMinSlots"])) or (slots > tonumber(SKCONF["sMaxSlots"]))) and (tonumber(SKCONF["sMinSlots"]) > 0) then
				user:SendData(Bot, "Your are in violation with this hubs Slots Rule: Min "..tonumber(SKCONF["sMinSlots"]).." Slots. - Max "..tonumber(SKCONF["sMaxSlots"]).." Slots.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hMinslots"] = SKHUBSTAT["hMinslots"] + 1
				SaveSKHUBSTAT() --// Min/Max Slots
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Min/Max Slots - ("..slots..")") end
				return 1
			end
		end
	end

Herodes

Good Job Snooze !!
A good way of doing it was missing from this forum ....
This one is spot on !
Bravo again :D

Snooze

#9
In that case ... here comes the rest ..


**NOTE**
- I have an extra profile added (Special)
- I only allow dc++ and oDC Clients


function DataArrival(user,data)
	----------------------------------------DataArrival-------------------------------------------
	----------------------------------- Rules Check START (hub/slots)--------------------------------
               hubsc = 0
		if ( strsub(data, 1, 12) == "$MyINFO $ALL" ) then
		if not (user.bOperator) or (GetProfileName(user.iProfile) == "VIP" or (GetProfileName(user.iProfile) == "Special")) then
              		 s,e,thubs,slots = strfind(data,  "H:([%d%/]+),S:(%d+)%S*>")
				if thubs==nil or slots==nil then
					user:SendData(Bot, "Your Client did not respond with proper tag!! - Latest allowed clients can be found here: [URL]http://www.snooze.no-ip.com/sk/viewforum.php?f=25[/URL]")
					user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
					user:Disconnect()
					SKHUBSTAT["hBadClient"] = SKHUBSTAT["hBadClient"] + 1
					SaveSKHUBSTAT()
						if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Bad Client tag - ("..data..")") end
					return
				end
             				if tonumber(thubs) == nil then
                 				gsub(thubs, "(%d+)", function (num)
                     				hubsc = hubsc +tonumber(num)
                 			end)
               				else
                  				hubsc = tonumber(thubs)
              				end
               			slots = tonumber(slots)
			if slots < (tonumber(SKCONF["sHSRatio"])*hubsc) then
				user:SendData(Bot, "Your are in violation with this hubs Hub/Slot Ratio: '"..tonumber(SKCONF["sHSRatio"]).." Slot per Hub'")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hSlotRatio"] = SKHUBSTAT["hSlotRatio"] + 1
				SaveSKHUBSTAT() --// Hub/Slot Ratio
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Ratio - ("..(tonumber(SKCONF["sHSRatio"])*hubsc)..")") end
				return 1
			elseif (hubsc > tonumber(SKCONF["sMaxHubs"])) and (tonumber(SKCONF["sMaxHubs"]) > 0) then
				user:SendData(Bot, "Your are in violation with this hubs Max Hub Rule: Max "..tonumber(SKCONF["sMaxHubs"]).." Hubs.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hMaxhubs"] = SKHUBSTAT["hMaxhubs"] + 1
				SaveSKHUBSTAT() --// Max Hubs
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Max Hubs - ("..hubsc..")") end
				return 1
			elseif ((slots < tonumber(SKCONF["sMinSlots"])) or (slots > tonumber(SKCONF["sMaxSlots"]))) and (tonumber(SKCONF["sMinSlots"]) > 0) then
				user:SendData(Bot, "Your are in violation with this hubs Slots Rule: Min "..tonumber(SKCONF["sMinSlots"]).." Slots. - Max "..tonumber(SKCONF["sMaxSlots"]).." Slots.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hMinslots"] = SKHUBSTAT["hMinslots"] + 1
				SaveSKHUBSTAT() --// Min/Max Slots
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Min/Max Slots - ("..slots..")") end
				return 1
			end
		end
	end
	----------------------------------- Rules Check (share)--------------------------------
	if (GetProfileName(user.iProfile) == "VIP") then
		if ( strsub(data, 1, 12) == "$MyINFO $ALL" ) then
		local s,e,iUserShare = strfind(data, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
		iUserShare = format("%0.2f", iUserShare/(1024*1024*1024))
			if tonumber(iUserShare) < tonumber(SKCONF["VipShare"]) then
				user:SendData(Bot, "You have not met the minimum VIP share size of "..SKCONF["VipShare"].." GB.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hVIPMinshare"] = SKHUBSTAT["hVIPMinshare"] + 1
				SaveSKHUBSTAT()
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - VIP Share - ("..tonumber(iUserShare)..")") end
				return 1
			end
		end
	elseif (GetProfileName(user.iProfile) == "Special") then
		if ( strsub(data, 1, 12) == "$MyINFO $ALL" ) then
		local s,e,iUserShare = strfind(data, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
		iUserShare = format("%0.2f", iUserShare/(1024*1024*1024))
			if tonumber(iUserShare) < tonumber(SKCONF["SpecialShare"]) then
				user:SendData(Bot, "You have not met the minimum Special share size of "..SKCONF["SpecialShare"].." GB.")
				user:SendData(Bot, "You are being redirected to another cool hub... Thanx for stopping here.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hSpecialMinshare"] = SKHUBSTAT["hSpecialMinshare"] + 1
				SaveSKHUBSTAT()
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Special Share - ("..tonumber(iUserShare)..")") end
				return 1
			end
		end
	elseif not (user.bOperator) or (GetProfileName(user.iProfile) == "VIP" or (GetProfileName(user.iProfile) == "Special")) then
		if ( strsub(data, 1, 12) == "$MyINFO $ALL" ) then
		local s,e,iUserShare = strfind(data, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
		iUserShare = format("%0.2f", iUserShare/(1024*1024*1024))
				hMinShare = tonumber(SKCONF["sMinShare"])
			if tonumber(iUserShare) < hMinShare then
				user:SendData(Bot, "You have not met the minimum share size of "..hMinShare.." GB.")
				user:SendData("$ForceMove "..frmHub:GetRedirectAddress())
				user:Disconnect()
				SKHUBSTAT["hMinshare"] = SKHUBSTAT["hMinshare"] + 1
				SaveSKHUBSTAT()
					if SKCONF["sDeBug"] == "ON" then SendPmToNick(HubOwner,Bot, user.sName.." - Min Share - ("..tonumber(iUserShare)..")") end
				return 1
			end
		end
	----------------------------------- Rules Check (client check)--------------------------------
	if SKCONF.BadClient == "ON" then
		if ( strsub(data, 1, 12) == "$MyINFO $ALL" ) then 
		if not (user.bOperator) or (GetProfileName(user.iProfile) == "VIP" or (GetProfileName(user.iProfile) == "Special")) then
				if not (strfind(data,"

This is made with alot of help from user in here ... so I'm only happy to give something back ;)

Please post any updates you may make here ;)


**Snooze

Snooze

Wondering - would it be an idea to stop the $GetNickList from being executed from the clients being disconnected ?

SMF spam blocked by CleanTalk