Author Topic: Script runs twice  (Read 8354 times)

Lunarbunny

  • Newbie
  • *
  • Posts: 6
Script runs twice
« on: December 25, 2006, 03:07:53 PM »
I have a script that appears to work properly - except it runs everything twice. It's mostly functional this way, but it's the reason for the .5s and also why the test ShowDialog I put in is commented out (it shows up twice). I'm running it in IceChat 7 (I'm used to vbscript now, so I'm not using the mIRC style stuff). I have not tested it in 5.5

I would use addtimedban but I don't have 250 in the channel I'm doing this in. #/dev/null is my testing channel.

Code: [Select]
'Profanity recording and tempbanning
'Created by Jacob Smith
'v1.1

Dim strIni, intTimerNumber, objTimeBanDlg
strIni="expletives.ini"
intTimerNumber = CInt(Rnd()*5000+251)
objTimeBanDlg = CreateDialog("Current Running timed bans",150,100,300,200)
'ShowDialog objTimeBanDlg

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
    If UCase(Channel) = "#/DEV/NULL" Or UCase(Channel) = "#WARROCK" Then
        Dim strNickAtHost, intHostmask, strHostmask, intHostLength
        strNickAtHost = Channel&" ; "&Nickname&"!"&Host
        intHostmask = InStr(Host,"@")
        intHostLength = Len(Host)
        strHostmask = Right(Host,(intHostLength - intHostmask))

        searchForExp "EXPLETIVES L1","OFFENDERS L1",Message,true,false,strNickAtHost,Channel,Nickname,strHostmask,ServerNumber
        searchForExp "EXPLETIVES L2","OFFENDERS L2",Message,false,false,strNickAtHost,Channel,Nickname,strHostmask,ServerNumber
        searchForExp "QUESTIONABLE","OFFENDERS Q",Message,false,true,strNickAtHost,Channel,Nickname,strHostmask,ServerNumber
        searchForExp "BANNED","OFFENDERS B",Message,false,false,strNickAtHost,Channel,Nickname,strHostmask,ServerNumber

    End If
End Sub

Sub searchForExp(strSection,strOffSection,Message,blnBan,blnIsQuestionable,strNickAtHost,Channel,Nickname,Host,ServerNumber)
        Dim dblNumOffenses,dblOffTimes

        For i = 1 to CInt(GetIniFile(strIni,strSection,"NUM","0"))
            If InStr(UCase(Message),GetIniFile(strIni,strSection,CStr(i),"#k$(ksops#@")) > 0 Then

                If blnIsQuestionable Then
                    dblNumOffenses = CDbl(GetIniFile(strIni,"OFFENDERS",strNickAtHost,"0"))
                    WriteINIFile strIni,"OFFENDERS",strNickAtHost,CStr(dblNumOffenses)
                Else
                    dblNumOffenses = CDbl(GetIniFile(strIni,"OFFENDERS",strNickAtHost,"0"))+.5
                    WriteINIFile strIni,"OFFENDERS",strNickAtHost,CStr(dblNumOffenses)
                End If

                dblOffTimes = CDbl(GetIniFile(strIni,strOffSection,strNickAtHost,"0"))+.5
                WriteINIFile strIni,strOffSection,strNickAtHost,CStr(dblOffTimes)

                If blnBan Then
                    SendCommand "/cs "&Channel&" kickban "&Nickname&" No swearing in "&Channel&"! 5 minute ban!",ServerNumber
                    SendCommand "/timer "&intTimerNumber&" 1 300 /cs "&Channel&" unban *!*@"&Host,ServerNumber
                    intTimerNumber = intTimerNumber + 1
                End If
            End If
        Next
End Sub
It does its job - it'll find and record, and for the bad stuff, ban for 5 minutes. But I find it annoying that it likes to run itself twice, even for the stuff that isn't in the ONTEXT subroutine.
« Last Edit: December 26, 2006, 01:45:18 AM by Lunarbunny »

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Script runs twice
« Reply #1 on: December 25, 2006, 09:42:42 PM »
You most likely have the script file loaded twice then.
Check to see if you have the file loaded 2 times.
The IceChat God

Lunarbunny

  • Newbie
  • *
  • Posts: 6
Re: Script runs twice
« Reply #2 on: December 26, 2006, 01:39:47 AM »
Ok, as this is the same project, I'll put it in the same thread. (Oh, and yes it was loaded twice  :oops:)

I'm trying to use the ALIASES function; however, it doesn't seem to pick up (might be that I'm in IC7).
EDIT: I'm messing with using the OUTTEXT function instead.
Code: [Select]
Function OUTTEXT(OutgoingText)
    If UCase(OutgoingText) = "!SBLIST" Then
        ShowDialog objTimeBanDlg
        OUTTEXT = ""
    Else
        OUTTEXT = OutgoingText   
    End If
End Function
However, now that I can bring up the dialog on demand, I found that it only opens once. Once it's closed I have to reset the script to make it open again.


Also, the dialog I'm messing with seems to be always on top. Is there a way to stop that or is it just stuck that way?
« Last Edit: December 26, 2006, 02:49:13 AM by Lunarbunny »

DarkStar

  • Full Member
  • ***
  • Posts: 135
  • Scripts for Praise
    • CorpseCorp
Re: Script runs twice
« Reply #3 on: December 26, 2006, 05:13:30 AM »
the Aliases function has been removed from Icechat 7, As it is now replace by the mIRC style scripting.

Quote from: Icechat7 Readme
alias aliasname {
enter your command here
}

For Example:

alias sayhello {
say Hello everyone , how are you today
}

So, now /sayhello will do just that.

To fix the second problem just dim the window outside of the subs.

Code: [Select]
Dim MyDialog
Sub openmydialog()
mydialog=CreateDialog("My Dialog",100,100,100,100)
End Sub

Sadly, I don't know if you can fix the third one. Cheers.
This message brought to you by the Wonderful Wizard of Oz.

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Script runs twice
« Reply #4 on: December 26, 2006, 10:51:47 AM »
Dialogs are always on top. This is the way they are made. Pretty much figured that people would use dialogs immediately, need them to be on top.
As for showing the Dialog, and it doesnt show again.  Recreating it each time I think works as well.
When the dialog is closed, the window is destroyed, so you need to re-create it, iirc.
The IceChat God

Lunarbunny

  • Newbie
  • *
  • Posts: 6
Re: Script runs twice
« Reply #5 on: December 26, 2006, 06:23:11 PM »
Hmmmph. Kinda want it to be a persistent list of all current running swear bans, with their times, etc. Therefore it'll be a pain in the butt to re-create it every time. Guess I could throw the data in an ini but still...

*starts scripting it to read from an ini*

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Script runs twice
« Reply #6 on: December 26, 2006, 06:59:18 PM »
If you dont close the window, you can continue using it.
The IceChat God

Lunarbunny

  • Newbie
  • *
  • Posts: 6
Re: Script runs twice
« Reply #7 on: December 27, 2006, 01:58:42 AM »
Well, it's a mess, and my usual lack of commenting is probably a really bad thing, but this works, or at least hasn't screwed up yet.
Code: [Select]
'Profanity recording and tempbanning
'Created by Jacob Smith (Lunarbunny)
'v1.3

SendCommand "/echo Lunarbunny's IceChat swear script v1.3 initiated"

Dim strIni, intTimerNumber, intTBListBox, intTimerListBox, objTimeBanDlg, intExtendEditBox, blnDialogStatus, blnRemoveFromDialog
strIni="expletives.ini"
intTimerNumber = CInt(Rnd(234)*5000+251)
intTBListBox = 224
intTimerListBox = 227
intExtendEditBox = 230
blnDialogStatus = true
blnRemoveFromDialog = true

Dim intArrL1Size, intArrL2Size, intArrQSize, intArrBSize
intArrL1Size = CInt(GetIniFile(strIni,"EXPLETIVES L1","num","0"))
intArrL2Size = CInt(GetIniFile(strIni,"EXPLETIVES L2","num","0"))
intArrQSize = CInt(GetIniFile(strIni,"QUESTIONABLE","num","0"))
intArrBSize = CInt(GetIniFile(strIni,"BANNED","num","0"))

Dim arrL1Exp(), arrL2Exp(), arrQExp(), arrBExp()
ReDim arrL1Exp(intArrL1Size), arrL2Exp(intArrL2Size), arrQExp(intArrQSize), arrBExp(intArrBSize)
For i = 0 to (intArrL1Size-1)
    arrL1Exp(i) = GetIniFile(strIni,"EXPLETIVES L1",CStr(i+1),"SDk3420#$#$")
Next
For i = 0 to (intArrL2Size-1)
    arrL2Exp(i) = GetIniFile(strIni,"EXPLETIVES L2",CStr(i+1),"SDk3420#$#$")
Next
For i = 0 to (intArrQSize-1)
    arrQExp(i) = GetIniFile(strIni,"QUESTIONABLE",CStr(i+1),"SDk3420#$#$")
Next
For i = 0 to (intArrBSize-1)
    arrBExp(i) = GetIniFile(strIni,"BANNED",CStr(i+1),"SDk3420#$#$")
Next


Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
    If UCase(Channel) = "#/DEV/NULL" Or UCase(Channel) = "#WARROCK" Or UCase(Channel) = "#WR.BETA" Then
        Dim strNickAtHost, intHostmask, strHostmask, intHostLength
        strNickAtHost = Channel&" ; "&Nickname&"!"&Host
        intHostmask = InStr(Host,"@")
        intHostLength = Len(Host)
        strHostmask = Right(Host,(intHostLength - intHostmask))

        searchForExp Message,strNickAtHost,Channel,Nickname,strHostmask,ServerNumber

    End If
End Sub


Sub ONACTION(Message,Channel,Nickname,Host,ServerNumber)
    If UCase(Channel) = "#/DEV/NULL" Or UCase(Channel) = "#WARROCK" Or UCase(Channel) = "#WR.BETA" Then
        Dim strNickAtHost, intHostmask, strHostmask, intHostLength
        strNickAtHost = Channel&" ; "&Nickname&"!"&Host
        intHostmask = InStr(Host,"@")
        intHostLength = Len(Host)
        strHostmask = Right(Host,(intHostLength - intHostmask))

        searchForExp Message,strNickAtHost,Channel,Nickname,strHostmask,ServerNumber

    End If
End Sub


Function OUTTEXT(OutgoingText)
    If UCase(OutgoingText) = "!SBLIST" Then
        blnDialogStatus = true
        swearBanDlg
        OUTTEXT = ""
    ElseIf UCase(OutgoingText) = "!SBLISTOFF" Then
        blnDialogStatus = false
        SendCommand "/echo Swear ban list turned off"
        OUTTEXT = ""
    Else
        OUTTEXT = OutgoingText   
    End If
End Function

Sub searchForExp(Message,strNickAtHost,Channel,Nickname,Host,ServerNumber)
    If Not ISOP(Nickname,Channel,ServerNumber) Then
        Dim dblNumOffenses, dblOffTimes

        For i = 0 to (intArrL1Size-1)
            If InStr(UCase(Message),arrL1Exp(i)) > 0 Then
                dblNumOffenses = CDbl(GetIniFile(strIni,"OFFENDERS",strNickAtHost,"0"))+1
                WriteINIFile strIni,"OFFENDERS",strNickAtHost,CStr(dblNumOffenses)

                dblOffTimes = CDbl(GetIniFile(strIni,"OFFENDERS L1",strNickAtHost,"0"))+1
                WriteINIFile strIni,"OFFENDERS L1",strNickAtHost,CStr(dblOffTimes)

                addTimeBan strNickAtHost,Channel,Nickname,Host,ServerNumber

                SendCommand "/notice "&Nickname&" Please do not use that sort of language/discuss that in "&Channel,ServerNumber
            End If
        Next

        For i = 0 to (intArrL2Size-1)
            If InStr(UCase(Message),arrL2Exp(i)) > 0 Then
                dblNumOffenses = CDbl(GetIniFile(strIni,"OFFENDERS",strNickAtHost,"0"))+1
                WriteINIFile strIni,"OFFENDERS",strNickAtHost,CStr(dblNumOffenses)

                dblOffTimes = CDbl(GetIniFile(strIni,"OFFENDERS L2",strNickAtHost,"0"))+1
                WriteINIFile strIni,"OFFENDERS L2",strNickAtHost,CStr(dblOffTimes)

                SendCommand "/notice "&Nickname&" Please do not use that sort of language/discuss that in "&Channel,ServerNumber
            End If
        Next

        For i = 0 to (intArrQSize-1)
            If InStr(UCase(Message),arrQExp(i)) > 0 Then
                dblNumOffenses = CDbl(GetIniFile(strIni,"OFFENDERS",strNickAtHost,"0"))
                WriteINIFile strIni,"OFFENDERS",strNickAtHost,CStr(dblNumOffenses)

                dblOffTimes = CDbl(GetIniFile(strIni,"QUESTIONABLE",strNickAtHost,"0"))+1
                WriteINIFile strIni,"QUESTIONABLE",strNickAtHost,CStr(dblOffTimes)
            End If
        Next

        For i = 0 to (intArrBSize-1)
            If InStr(UCase(Message),arrBExp(i)) > 0 Then
                dblNumOffenses = CDbl(GetIniFile(strIni,"OFFENDERS",strNickAtHost,"0"))+1
                WriteINIFile strIni,"OFFENDERS",strNickAtHost,CStr(dblNumOffenses)

                dblOffTimes = CDbl(GetIniFile(strIni,"BANNED",strNickAtHost,"0"))+1
                WriteINIFile strIni,"BANNED",strNickAtHost,CStr(dblOffTimes)

                addTimeBan strNickAtHost,Channel,Nickname,Host,ServerNumber
            End If
        Next
    End If
End Sub


Sub ONNOTICE(Message,Nickname,Host,ServerNumber)
    If blnRemoveFromDialog Then
    If (UCase(Nickname) = "CHANSERV" Or Nickname = MyNickName(ServerNumber)) And (InStr(UCase(Message),"REMOVED") > 0 Or InStr(UCase(Message),"NO BAN FOUND") > 0) Then
        Dim intHostmask2, strHostmask2, intHostLength2, strIniHost

For i = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
            strIniHost = GetIniFile(strIni,"CURRENT BANS",CStr(i),"#$kld905")
            intHostmask2 = InStr(strIniHost,"@")
            intHostLength2 = Len(strIniHost)
            strHostmask2 = Right(strIniHost,(intHostLength2 - intHostmask2))

            If InStr(Message,strHostmask2) > 0 Then
                For j = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
                    If InStr(GetIniFile(strIni,"CURRENT BANS",CStr(j),""),strHostmask2) > 0 Then
                        For k = j to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
                            WriteIniFile strIni,"CURRENT BANS",CStr(k),GetIniFile(strIni,"CURRENT BANS",CStr(k+1),"")
                            WriteIniFile strIni,"CURRENT BANS","t"&CStr(k),GetIniFile(strIni,"CURRENT BANS","t"&CStr(k+1),"")
                            WriteIniFile strIni,"CURRENT BANS","tid"&CStr(k),GetIniFile(strIni,"CURRENT BANS","tid"&CStr(k+1),"")
                            WriteIniFile strIni,"CURRENT BANS","sn"&CStr(k),GetIniFile(strIni,"CURRENT BANS","tid"&CStr(k+1),"")
                        Next
                        WriteIniFile strIni,"CURRENT BANS","num",CStr(CInt(GetIniFile(strIni,"CURRENT BANS","num","1"))-1)
                    End If
                Next
            End If
        Next
        swearBanDlg
    End If
    ElseIf Not blnRemoveFromDialog Then
        blnRemoveFromDialog = true
    End If
End Sub


Sub ONQUERY(Message,Nickname,Host,ServerNumber)
    If blnRemoveFromDialog Then
    If UCase(Nickname) = "CHANSERV" And (InStr(UCase(Message),"REMOVED") > 0 Or InStr(UCase(Message),"NO BAN FOUND") > 0) Then
        Dim intHostmask2, strHostmask2, intHostLength2, strIniHost

For i = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
            strIniHost = GetIniFile(strIni,"CURRENT BANS",CStr(i),"#$kld905")
            intHostmask2 = InStr(strIniHost,"@")
            intHostLength2 = Len(strIniHost)
            strHostmask2 = Right(strIniHost,(intHostLength2 - intHostmask2))

            If InStr(Message,strHostmask2) > 0 Then
                For j = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
                    If InStr(GetIniFile(strIni,"CURRENT BANS",CStr(j),""),strHostmask2) > 0 Then
                        For k = j to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
                            WriteIniFile strIni,"CURRENT BANS",CStr(k),GetIniFile(strIni,"CURRENT BANS",CStr(k+1),"")
                            WriteIniFile strIni,"CURRENT BANS","t"&CStr(k),GetIniFile(strIni,"CURRENT BANS","t"&CStr(k+1),"")
                            WriteIniFile strIni,"CURRENT BANS","tid"&CStr(k),GetIniFile(strIni,"CURRENT BANS","tid"&CStr(k+1),"")
                            WriteIniFile strIni,"CURRENT BANS","sn"&CStr(k),GetIniFile(strIni,"CURRENT BANS","tid"&CStr(k+1),"")
                        Next
                        WriteIniFile strIni,"CURRENT BANS","num",CStr(CInt(GetIniFile(strIni,"CURRENT BANS","num","1"))-1)
                    End If
                Next
            End If
        Next
        swearBanDlg
    End If
    ElseIf Not blnRemoveFromDialog Then
        blnRemoveFromDialog = true
    End If
End Sub


Sub swearBanDlg
    If blnDialogStatus Then
        CloseDialog objTimeBanDlg
        objTimeBanDlg = CreateDialog("Current running timed bans",5,105,420,261)
        AddListBox objTimeBanDlg,1,20,351,210,intTBListBox
        AddListBox objTimeBanDlg,353,20,60,210,intTimerListBox
        AddLabel objTimeBanDlg,"Banned users:",1,1,351,18,30005
        AddLabel objTimeBanDlg,"Ends:",353,1,60,18,30008
        AddLabel objTimeBanDlg,"Extend by",1,219,67,19,30011
        AddEditBox objTimeBanDlg,"300",69,217,287,23,intExtendEditBox
        AddLabel objTimeBanDlg,"seconds",357,219,55,19,30014
        AddButton objTimeBanDlg,"Unban",1,240,136,30,1,0,"UnbanButton"
        AddButton objTimeBanDlg,"Extend Ban",138,240,138,30,1,0,"ExtBanButton"
        AddButton objTimeBanDlg,"Permaban",277,240,136,30,1,0,"PermBanButton"
        For i = 1 to 10
        ShowDialog objTimeBanDlg
        ClearItems intTBListBox,4
        ClearItems intTimerListBox,4
        Next
        For i = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))   
            AddItem intTBListBox,4,GetIniFile(strIni,"CURRENT BANS",CStr(i),"")
        Next

        For i = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
            AddItem intTimerListBox,4,GetIniFile(strIni,"CURRENT BANS","t"&CStr(i),"")
        Next
    End If
End Sub

Sub addTimeBan(strNickAtHost,Channel,Nickname,Host,ServerNumber)
    If Not ISOP(Nickname,Channel,ServerNumber) Then
        'Dim intTimeBanned, intTimesBanned
        'intTimeBanned = 5
        'Get

        SendCommand "/cs "&Channel&" addtimedban "&Nickname&" 5m No swearing in "&Channel&"! 5 minute ban!",ServerNumber
        SendCommand "/timer "&intTimerNumber&" 1 300 /notice "&MyNickName(ServerNumber)&" Ban removed for "&Nickname&"!"&Host,ServerNumber
        intTimerNumber = intTimerNumber + 1

        Dim intNumCurrentBans, strTimeNow
        intNumCurrentBans = CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
        intNumCurrentBans = intNumCurrentBans + 1
        WriteIniFile strIni,"CURRENT BANS","num",CStr(intNumCurrentBans)

        WriteIniFile strIni,"CURRENT BANS","tid"&intNumCurrentBans,CStr(intTimerNumber-1)
        WriteIniFile strIni,"CURRENT BANS",CStr(intNumCurrentBans),strNickAtHost

        Dim intMinutes, intHour
            intMinutes = Minute(Now)+5
            intHour = Hour(Now)

        If intMinutes >= 60 Then
            intMinutes = intMinutes - 60
            intHour = intHour + 1
            If intHour >= 24 Then
                intHour = intHour - 24
            End If
        End If

        If intMinutes < 10 Then
            WriteIniFile strIni,"CURRENT BANS","t"&CStr(intNumCurrentBans),intHour&":0"&intMinutes
        Else
            WriteIniFile strIni,"CURRENT BANS","t"&CStr(intNumCurrentBans),intHour&":"&intMinutes
        End If

        WriteIniFile strIni,"CURRENT BANS","sn"&CStr(intNumCurrentBans),CStr(ServerNumber)
   
        swearBanDlg
    End If
End Sub


Sub UnbanButton_Clicked
    Dim strListItem, intListIndex, intListHostmask, intListHostLength, strListHostname, intTimerID, intListChannel, strListChannel,_
        intServerNumber
    If Not GetIniFile(strIni,"CURRENT BANS","num","0") = 0 Then
        strListItem = GetListItem(intTBListBox,4)
        intListIndex = GetListItem(intTBListBox,4,1)
        intServerNumber = CInt(GetIniFile(strIni,"CURRENT BANS","sn"&CStr(intListIndex+1),"0"))

        intListHostmask = InStr(strListItem,"@")
        intListHostLength = Len(strListItem)
        strListHostmask = Right(strListItem,(intListHostLength - intListHostmask))

        intListChannel = InStr(strListItem,";")
        strListChannel = Left(strListItem,(intListChannel-2))

        intTimerID = CInt(GetIniFile(strIni,"CURRENT BANS","tid"&CStr(intListIndex+1),"0"))
        SendCommand "/timer "&intTimerID&" off"

        SendCommand "/cs "&strListChannel&" delban *!*@"&strListHostmask,intServerNumber
    End If
End Sub


Sub ExtBanButton_Clicked
    Dim strListItem, intListIndex, intListHostmask, intListHostLength, strListHostname, intTimerID, intListChannel,_
        strListChannel, intIniTime, intMinute, intExtend, intTimeDifference, intNewTimer, intServerNumber

    If Not GetIniFile(strIni,"CURRENT BANS","num","0") = 0 Then
        strListItem = GetListItem(intTBListBox,4)
        intListIndex = GetListItem(intTBListBox,4,1)
        intExtend = CInt(GetText(intExtendEditBox))
        strIniTime = GetIniFile(strIni,"CURRENT BANS","t"&CStr(intListIndex+1),"")
        intServerNumber = CInt(GetIniFile(strIni,"CURRENT BANS","sn"&CStr(intListIndex+1),"0"))

        intListHostmask = InStr(strListItem,"@")
        intListHostLength = Len(strListItem)
        strListHostmask = Right(strListItem,(intListHostLength - intListHostmask))

        intMinute = CInt(Right(strIniTime,2))
        intTimeDifference = intMinute - Minute(Now)
        If intTimeDifference < 0 Then
            intTimeDifference = 60 + intTimeDifference
        End If
        intNewTimer = 60*intTimeDifference + intExtend

        Dim intMinutes, intHour
            intMinutes = intMinute+intTimeDifference
            If Len(strIniTime) = 5 Then
                intHour = CInt(Left(strIniTime,2))
            ElseIf Len(strIniTime) = 4 Then
                intHour = CInt(Left(strIniTime,1))
            End If

        If intMinutes >= 60 Then
            intMinutes = intMinutes - 60
            intHour = intHour + 1
            If intHour >= 24 Then
                intHour = intHour - 24
            End If
        End If

        If intMinutes < 10 Then
            WriteIniFile strIni,"CURRENT BANS","t"&CStr(intListIndex+1),intHour&":0"&intMinutes
        Else
            WriteIniFile strIni,"CURRENT BANS","t"&CStr(intListIndex+1),intHour&":"&intMinutes
        End If

        intListChannel = InStr(strListItem,";")
        strListChannel = Left(strListItem,(intListChannel-2))

        intTimerID = CInt(GetIniFile(strIni,"CURRENT BANS","tid"&CStr(intListIndex+1),"0"))
        blnRemoveFromDialog = false
        SendCommand "/cs "&strListChannel&" delban *!*@"&strListHostmask,intServerNumber
        SendCommand "/cs "&strListChannel&" addtimedban *!*@"&strListHostmask&" "&intNewTimer&"s Swearing",intServerNumber
        SendCommand "/timer "&intTimerID&" off"
        SendCommand "/timer "&intTimerID&" 1 "&intNewTimer&" /notice "&MyNickName(ServerNumber)&" Ban removed for "&Nickname&"!"&Host,intServerNumber

        swearBanDlg
    End If
End Sub


Sub PermBanButton_Clicked
    Dim strListItem, intListIndex, intListHostmask, intListHostLength, strListHostname, intTimerID, intListChannel, strListChannel,_
        intServerNumber
    If Not GetIniFile(strIni,"CURRENT BANS","num","0") = 0 Then
        strListItem = GetListItem(intTBListBox,4)
        intListIndex = GetListItem(intTBListBox,4,1)
        intServerNumber = CInt(GetIniFile(strIni,"CURRENT BANS","sn"&CStr(intListIndex+1),"0"))

        intListHostmask = InStr(strListItem,"@")
        intListHostLength = Len(strListItem)
        strListHostmask = Right(strListItem,(intListHostLength - intListHostmask))

        intListChannel = InStr(strListItem,";")
        strListChannel = Left(strListItem,(intListChannel-2))

        intTimerID = CInt(GetIniFile(strIni,"CURRENT BANS","tid"&CStr(intListIndex+1),"0"))
        SendCommand "/timer "&intTimerID&" off"

        Dim intHostmask2, strHostmask2, intHostLength2, strIniHost

For i = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
            strIniHost = GetIniFile(strIni,"CURRENT BANS",CStr(i),"#$kld905")
            intHostmask2 = InStr(strIniHost,"@")
            intHostLength2 = Len(strIniHost)
            strHostmask2 = Right(strIniHost,(intHostLength2 - intHostmask2))

            For j = 1 to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
                If InStr(GetIniFile(strIni,"CURRENT BANS",CStr(j),""),strHostmask2) > 0 Then
                    For k = j to CInt(GetIniFile(strIni,"CURRENT BANS","num","0"))
                        WriteIniFile strIni,"CURRENT BANS",CStr(k),GetIniFile(strIni,"CURRENT BANS",CStr(k+1),"")
                        WriteIniFile strIni,"CURRENT BANS","t"&CStr(k),GetIniFile(strIni,"CURRENT BANS","t"&CStr(k+1),"")
                        WriteIniFile strIni,"CURRENT BANS","tid"&CStr(k),GetIniFile(strIni,"CURRENT BANS","tid"&CStr(k+1),"")
                        WriteIniFile strIni,"CURRENT BANS","sn"&CStr(k),GetIniFile(strIni,"CURRENT BANS","tid"&CStr(k+1),"")
                    Next
                    WriteIniFile strIni,"CURRENT BANS","num",CStr(CInt(GetIniFile(strIni,"CURRENT BANS","num","1"))-1)
                    SendCommand "/cs "&strListChannel&" addban *!*@"&strHostmask2&" Banned from swear script ban dialog",intServerNumber
                End If
            Next
        Next
        swearBanDlg
    End If
End Sub

The .ini is here (Warning! It is a swear script so it's got a lot of profanity)

My little extra is that it pops up a window (or refreshes it) when you type in !sblist, if a new ban is issued, or if a ban ends. It lists the channel and full hostname as well as the hour and minute the ban will end, as well as an unban, extend ban by the entered amount of seconds, and permaban button. Currently you have to adjust the script to change which channels it runs in and the default ban time, as well as the ban message, but that can easily be changed. I realize that it calls the ini more than necessary, which I could change to a variable in some instances, but I didn't want to lose my groove. Poke, prod, comment all you like.
« Last Edit: January 11, 2007, 04:22:23 PM by Lunarbunny »