ironic but help with dc++ check

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
TMM
Posts: 47
Joined: 2003-01-03 19:50
Location: leeds UK
Contact:

ironic but help with dc++ check

Post by TMM » 2003-02-22 15:57

hiya, doing a dc++ check for slots -hubs
however can i get anyversion to run?????? NOPE can i helll

for some reason when it comes to checking slot against hubs
i get Microsoft VBScript runtime error: Overflow

for If (cdbl(sTmp)/iCHubs) < SlotHubs Then in otherwords
it wont calculate slots divided by hubs = less than slot per hub

here is full code for my dc++ checking

If NOT curUser.bOperator then 'if they aint an op

sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next

If CheckDcpp Then 'if allow DC++ box is ticked
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next


If InStr(1, sDCI, "<++ V:") > 1 Then

sDCI = AfterFirst(sDCI, "<++ V:")
sDCI = AfterFirst(sDCI, "H:")
sTmp = BeforeFirst(sDCI, ">")
If InStr(1, sTmp, ",") Then sTmp = BeforeFirst(sTmp, ",")
iCHubs = CDbl(sTmp)

sDCI = AfterFirst(sDCI, "S:")
sTmp = BeforeFirst(sDCI, ">")
If InStr(1, sTmp, ",") Then sTmp = BeforeFirst(sTmp, ",")

If iCHubs > Mhubs Then
curUser.SendChatMessage CStr(botname), "Your in too many hubs the limit is " & Mhubs & ". Disconnect from some hubs and try again."
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If

If (cdbl(sTmp)/iCHubs) < SlotHubs Then
curUser.SendChatMessage CStr(botname), "You have too few slots to connect here. You must have at least " & SlotHubs & " slots for each hub that you connect. Open some more slots or disconnect from some hubs and try again."
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If

If InStr(1,sDCI,"<++ V:") > 1 Then
curUser.SendChatMessage cstr(botname), "An attempt to fake your description line was detected. Nice try lamer. Goodbye!"
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If [/code][/quote]
ashes to ashes, dust to dust, if the dope dont get you. The acid must

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-02-23 04:45

Slots divided by hubs is a tricky thing to do, because if it's an OP only connected to your hub, you'll end up with a division by 0 (since the dc++ tag will show them with H:0). Same if it's someone registered in the all the hubs they're connected to (whether they're an OP in these hubs or not, actually)

-----

Also, in case it is the whole code for your dc++ checking, you don't assign any value to Mhubs anywhere, so it will be an empty variable.

-----

Finally,

Code: Select all

If NOT curUser.bOperator then 'if they aint an op 

sDCI = sCurData 
For x = 1 To 2 
sDCI = AfterFirst(sDCI, "$") 
Next 

If CheckDcpp Then 'if allow DC++ box is ticked 
sDCI = sCurData 
For x = 1 To 2 
sDCI = AfterFirst(sDCI, "$") 
Next 
is exactly the same as :

Code: Select all

If CheckDcpp And Not curUser.bOperator Then
sDCI = sCurData 
For x = 1 To 2 
sDCI = AfterFirst(sDCI, "$") 
Next 
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

TMM
Posts: 47
Joined: 2003-01-03 19:50
Location: leeds UK
Contact:

Post by TMM » 2003-02-23 08:40

yeah that was a mistake

i know about the iDC thing, and it was fixed it was just cos i was chopping and pasting from another txt file were i had 4 diff versions of dc++ check going

i decided to do away with slots against hubs
and went with slot ratio
so for 1 hub u need 1 slot

however

lol max hubs aint working now
so i have peeps with like 100 hubs 100 slots, strange thing is
if it aint getting the hub amount, then this wouldent be working
but it is?????

lol

so
ashes to ashes, dust to dust, if the dope dont get you. The acid must

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-02-23 14:34

so i have peeps with like 100 hubs 100 slots, strange thing is
if it aint getting the hub amount, then this wouldent be working
but it is?????
If at the time you check "If iCHubs > Mhubs", both variables are equal to 0. Then "If 0 > 0 " will always be False, and it will work :wink:

Also, remember that for comparison operators :
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric, then a numeric comparison is performed, using 0 as the Empty expression.
- If one expression is Empty and the other is a string, then a string comparison is performed, using a zero-length string ("") as the Empty expression

As you can see, many cases can lead to this expression being false, even if you aren't getting the hub amount.

-----

How about you paste just 1 version of the checking script and we see from there ? (with the If/End If indented, it would be nice =)
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

TasMan
Posts: 196
Joined: 2003-01-03 08:31
Location: Canada
Contact:

Post by TasMan » 2003-02-23 15:19

If might be faster to do this...it's also easier to add new things :o)

Code: Select all

'Assuming you've parsed out the dc++ tag (called sTag)
'sTag = <++ V:*,M:*,H:*,S:*>

Dim aTag, ub

sTag = Mid$(sTag, 5)
sTag = Left$(sTag, InStr(1, sTag, ">") - 1)
aTag = Split(sTag, ",")

For i = 0 To 3
  aTag(i) = Mid$(aTag(i), 3)
Next

'aTag(0) = Version
'aTag(1) = Mode
'aTag(2) = Hubs
'aTag(3) = Slots

ub = UBound(aTag)

If ub > 3 Then
  For i = 4 To ub
    Select Case Left(aTag(i), 1)
      Case "L", "B"
        'aTag(i) = Bandwidth limiter
    End Select
  Next
End If

TasMan
Posts: 196
Joined: 2003-01-03 08:31
Location: Canada
Contact:

Post by TasMan » 2003-02-23 15:20

oops....all Left$() and Mid$() should be Left() and Mid()...

chrish4321
Posts: 5
Joined: 2003-03-02 01:50

RegExps

Post by chrish4321 » 2003-03-02 02:02

Ripping off the last post a bit, this might be a more adaptable way to pull out tag info; the RegExps match the data pretty easily, rather than depending on the position of the information.

Code: Select all

'Assuming you've parsed out the dc++ tag (called sTag) 
'sTag = <++ V:*,M:*,H:*,S:*> 

  Dim slotsre, hubsre, numre
  Set slotsre = new regexp
  Set hubsre = new regexp
  Set numre = new regexp
  ' isolate the tag with it's corresponding number
  slotsre.Pattern = "S:[0-9]+[^0-9]" ' Hub "H:" tag 
  hubsre.Pattern = "H:[0-9]+[^0-9]" ' Slot "S:" tag

' ... etc ...

  ' isolate the numbers from the fields
  numre.Pattern = "[0-9]+" 
 
  Dim numhubs, numslots

  ' apply the above-defined Regular Expressions to the description tag string

  numhubs = CInt(numre.execute(hubsre.execute(sTag)(0).Value)(0).Value) + 1

  numslots = CInt(numre.execute(slotsre.execute(sTag)(0).Value)(0).Value)

[/code]

smitty
Posts: 53
Joined: 2003-03-01 14:45

Post by smitty » 2003-03-08 20:22

Dim DppMaxHubs, DppMinSlots, DppMaxSlots, sBotName
Sub Main()
DppMaxHubs = "5"
DppMinslots = "2"
dppmaxslots = "10"
sBotName = "Hub-Security"
End Sub
Sub DataArival(curUser, sCurData)
If InStr(1, LCase(sCurData), LCase("$GetINFO "+curUser.sName+" "+curUser.sName))>0 then
'EXTRACT USERS INFO
iTheirInfo = curUser.sMyInfoString
iTheirFileDescription = BeforeFirst(AfterFirst(AfterFirst(iTheirInfo,"$ALL ")," "),"$")
Dim dpphubs, dppslots, dppversion
If InStr(1, CStr(iTheirFileDescription), CStr("<++ V:"), vbTextCompare) = 0 Then
dppversion = 1.0091
dpphubs = "Neo-Modus"
dppslots = "DC"
Else
dppversion = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "<++ V:"), ",")
dpphubs = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "H:"), ",")
dppslots = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "S:"), ">")
If InStr(1, CStr(dppslots), CStr("L:"), vbTextCompare) > 0 Or InStr(1, CStr(dppslots), CStr("B:"), vbTextCompare) > 0 Then
curUser.PrivateMessage sBotName, "Bandwith limiter clients not allowed in this hub."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
If InStr(1, CStr(dppslots), CStr(","), vbTextCompare) > 0 Then
dppslots = BeforeFirst(CStr(dppslots), ",")
End If
If Int(dpphubs) > Int(DppMaxHubs) And ms = 0 Then
curUser.PrivateMessage sBotName, "" + CStr(DppMaxHubs) + " hubs max here. Your in " + CStr(dpphubs) + " hubs."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
If Int(dpphubs) >= 1 Then
If (Int(dppslots) / Int(dpphubs)) < Int(DppMinSlots) Then
curUser.PrivateMessage sBotName, "" + CStr(DppMinSlots) + " slots per hub minimum here. Your only sharing " + CStr(Int(dppslots) / Int(dpphubs)) + " slots per hub."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
End If
If Int(dppslots) > Int(DppMaxSlots) Then
curUser.PrivateMessage sBotName, "" + CStr(DppMaxSlots) + " slots maximum here. You have " + CStr((dppslots)) + " slots open."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
End Sub
Function BeforeFirst(sIn, sFirst)
BeforeFirst = Left(sIn, InStr(1, sIn, sFirst) - 1)
End Function
Function AfterFirst(sIn, sFirst)
AfterFirst = Right(sIn, Len(sIn) - InStr(1, sIn, sFirst) - (Len(sFirst) - 1))
End Function
Public Function AfterLast(sFrom, sAfterLast)
If InStr(1, sFrom, sAfterLast) Then
AfterLast = Right(sFrom, Len(sFrom) - InStrRev(sFrom, sAfterLast) - (Len(sAfterLast) - 1))
Else
AfterLast = ""
End If
End Function

just threw that together...hope it works

smitty
Posts: 53
Joined: 2003-03-01 14:45

Post by smitty » 2003-03-08 20:26

take the and ms out of this

If Int(dpphubs) > Int(DppMaxHubs) And ms = 0 Then

change like this

If Int(dpphubs) > Int(DppMaxHubs) Then

sorry for the mistake...converted it from a VB6 bot I'm writing and the ms is OPorNOT Function

Locked