Here is a script that parses modes and puts the modes that require a parameter in an array together with the parameter

`Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)`

ModeParser Mode,Channel,ServerNumber

End Sub

Sub ModeParser(Mode,Channel,ServerNumber)

Dim ModesWithParameters,ParameterModes(),ParameterModeNumber,OtherModes(),OtherModeNumber,ChangePosition,lFound

ModesWithParameters = "voblkeIfLj" 'modes that can (usually will) be followed by a parameter

ParameterModeNumber = 0

OtherModeNumber = 0

lFound = False

If InStr(Mode," ") > 0 then 'there are parameters

Modes = Left(Mode,InStr(Mode," ")-1)

Parameters = Mid(Mode,InStr(Mode," ")+1)

If InStr(Parameters," ") then

ParameterArray = Split(Parameters," ")

Else

Dim ParameterArray(0)

ParameterArray(0) = Parameters

End If

If Left(Modes,1) = "+" then 'no modes have been removed

For i = 1 to Len(Modes)

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then

ParameterModeNumber = ParameterNumber + 1

ElseIf Mid(Modes,i,1) <> "+" then

OtherModeNumber = OtherModeNumber + 1

End If

Next

ReDim ParameterModes(ParameterModeNumber-1)

ReDim OtherModes(OtherModeNumber-1)

ParameterModeNumber = 0

OtherModeNumber = 0

For i = 1 to Len(Modes)

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then

ParameterModes(ParameterModeNumber) = "+" & Mid(Modes,i,1)

ParameterModeNumber = ParameterModeNumber + 1

ElseIf Mid(Modes,i,1) <> "+" then

OtherModes(OtherModeNumber) = "+" & Mid(Modes,i,1)

OtherModeNumber = OtherModeNumber + 1

End If

Next

For i = 0 to UBound(ParameterModes)

ParameterModes(i) = ParameterModes(i) & " " & ParameterArray(i)

Next

ElseIf Left(Modes,1) = "-" And InStr(Modes,"+") = 0 then 'modes have been removed but no modes have been added

ModesWithParameters = "vobkeIfLj" 'the mode l doesn't take a parameter when it is removed

For i = 1 to Len(Modes)

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then

ParameterModeNumber = ParameterNumber + 1

ElseIf Mid(Modes,i,1) <> "-" then

OtherModeNumber = OtherModeNumber + 1

End If

Next

ReDim ParameterModes(ParameterModeNumber-1)

ReDim OtherModes(OtherModeNumber-1)

ParameterModeNumber = 0

OtherModeNumber = 0

For i = 1 to Len(Modes)

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then

ParameterModes(ParameterModeNumber) = "-" & Mid(Modes,i,1)

ParameterModeNumber = ParameterModeNumber + 1

ElseIf Mid(Modes,i,1) <> "-" then

OtherModes(OtherModeNumber) = "-" & Mid(Modes,i,1)

OtherModeNumber = OtherModeNumber + 1

End If

Next

For i = 0 to UBound(ParameterModes)

ParameterModes(i) = ParameterModes(i) & " " & ParameterArray(i)

Next

ElseIf Left(Modes,1) = "-" And InStr(Modes,"+") > 0 then 'some modes have been removed and some have been added

For i = 1 to Len(Modes)

If lFound = False then

ModesWithParameters = "vobkeIfLj"

Else

ModesWithParameters = "voblkeIfLj"

End If

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then

ParameterModeNumber = ParameterModeNumber + 1

ElseIf Mid(Modes,i,1) <> "-" And Mid(Modes,i,1) <> "+" then

OtherModeNumber = OtherModeNumber + 1

ElseIf Mid(Modes,i,1) = "+" then

lFound = True

End If

Next

ReDim ParameterModes(ParameterModeNumber-1)

ReDim OtherModes(OtherModeNumber-1)

ParameterModeNumber = 0

OtherModeNumber = 0

lFound = False

For i = 1 to Len(Modes)

If lFound = False then

ModesWithParameters = "vobkeIfLj"

Else

ModesWithParameters = "voblkeIfLj"

End If

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then

If lFound = False then

ParameterModes(ParameterModeNumber) = "-" & Mid(Modes,i,1)

ParameterModeNumber = ParameterModeNumber + 1

Else

ParameterModes(ParameterModeNumber) = "+" & Mid(Modes,i,1)

ParameterModeNumber = ParameterModeNumber + 1

End If

ElseIf Mid(Modes,i,1) <> "-" And Mid(Modes,i,1) <> "+" then

If lFound = False then

OtherModes(OtherModeNumber) = "-" & Mid(Modes,i,1)

OtherModeNumber = OtherModeNumber + 1

Else

OtherModes(OtherModeNumber) = "+" & Mid(Modes,i,1)

OtherModeNumber = OtherModeNumber + 1

End If

ElseIf Mid(Modes,i,1) = "+" then

lFound = True

End If

Next

For i = 0 to UBound(ParameterModes)

ParameterModes(i) = ParameterModes(i) & " " & ParameterArray(i)

Next

End If

For i = 0 to UBound(ParameterModes)

SendCommand "/echo -a " & ParameterModes(i)

Next

For i = 0 to UBound(OtherModes)

SendCommand "/echo -a " & OtherModes(i)

Next

End If

End Sub

The script doesn't do anything else than parse the modes, and right now it does nothing if a mode without parameters is set (which you won't need anyway) but I'll add that at some point. I did some testing, and it seems to work, but there might still be some bugs.

This part:

` For i = 0 to UBound(ParameterModes)`

SendCommand "/echo -a " & ParameterModes(i)

Next

For i = 0 to UBound(OtherModes)

SendCommand "/echo -a " & OtherModes(i)

Next

prints the arrays to the screen.

To pick out only bans, loop through all modes and only do something when you find a mode that starts with '+b' or '-b'

Load the script and play around with the modes and you'll see what the script actually does