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
IMHO its better they get motd and userlist... they can decide whether they wanna enter @ all :D
best check every time a new $MyINFO comes
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
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
it's not any faster but rather obvious to check whenever it changes
NewUserConnected gets called right after the first $MyINFO is received
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
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
Good Job Snooze !!
A good way of doing it was missing from this forum ....
This one is spot on !
Bravo again :D
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," user:SendData(Bot, "This hub ONLY allow DC++ and oDC++ Clients. - 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 - ("..data..")") end
return 1
end
s,e,dcVers = strfind(data, "++ V:0.(%d+)")
if (tonumber(dcVers) ~= nil) and (tonumber(dcVers) < 300) then
user:SendData(Bot, "Please update your client - 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 - ("..data..")") end
return 1
end
s,e,odcVers = strfind(data, "oDC V:5.(%d+)")
if (tonumber(odcVers) ~= nil) and (tonumber(odcVers) < 21) then
user:SendData(Bot, "Please update your client - 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 - ("..data..")") end
return 1
end
end
end
end
end
----------------------------------- Rules Check END ----------------------------------
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
Wondering - would it be an idea to stop the $GetNickList from being executed from the clients being disconnected ?