Author Topic: Channel Specific Stuff  (Read 3533 times)

TheCellist42

  • Full Member
  • ***
  • Posts: 143
    • TheCellist42.com
Channel Specific Stuff
« on: July 18, 2008, 03:23:11 PM »
Is There A Way To Make A Script Work In Specific Channels Only? I Tried This, But It Didn't Work, It Stopped Working For Some Reason.

Code: [Select]
chan_list = "#channel #channel2 #channel3"
 if instr(chan_list,lcase(channel))=-1 then Exit Sub

Any Ideas?
~ Sam
~ Visit my website at http://www.TheCellist42.com

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Channel Specific Stuff
« Reply #1 on: July 18, 2008, 07:50:41 PM »
not -1, it would be equal to 0.

Instr returns the character position of a string. Values start at 1, for position 1. If its 0, you have no match.
The IceChat God

TheCellist42

  • Full Member
  • ***
  • Posts: 143
    • TheCellist42.com
Re: Channel Specific Stuff
« Reply #2 on: July 18, 2008, 07:51:12 PM »
Thanks Snerf
~ Sam
~ Visit my website at http://www.TheCellist42.com

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: Channel Specific Stuff
« Reply #3 on: July 18, 2008, 11:41:16 PM »
the problem with that method is that it will run the scripts for channels like #channe, #chann, #chan, etc

Code: [Select]
Function CheckChannel(AllChannels,Chan)
AllChannels = LCase(AllChannels)
Chan = LCase(Chan)

CheckChannel = False

If Not InStr(AllChannels,",") > 0 then
  If Chan = AllChannels then CheckChannel = True

ElseIf InStr(AllChannels,",") > 0 then
  Chanlist = Split(AllChannels,",")
  For i = LBound(Chanlist) to UBound(Chanlist)
    If Chan = Chanlist(i) then CheckChannel = True
  Next

End If
End Function

this function will chek for the exact channels only, just send it the channel list with the channels separated by commas, and the channel to check for. It returns True if the channel is found in the list, otherwise it returns False
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Channel Specific Stuff
« Reply #4 on: July 18, 2008, 11:54:36 PM »
Yes indeed, very well done Morio.
The IceChat God