Author Topic: Auto Rejoin Script *NOW WITH EXTRA FLARE!*  (Read 8925 times)

DarkStar

  • Full Member
  • ***
  • Posts: 135
  • Scripts for Praise
    • CorpseCorp
Auto Rejoin Script *NOW WITH EXTRA FLARE!*
« on: August 06, 2008, 02:12:30 AM »
I decided to put together a auto rejoin on kick script that does more then the average one.

Channel Passwords
The average script will only retrieve the channel name and attempt to join it, but for channels with passwords (mode +k) These scripts will not work. This script will check the Favorite server lists to see if the channel is in the autojoin list, and if it is, if there is a password. If a password is present it will send the password along with the join command.

Options
  • Enabled - is the script on for this channel/network?
  • Delay - How long to wait before attempting to rejoin
  • Attempts - How many attempts to make, does not work if delay is 0

All options can be set on a global, network specific and channel specific scale.

Script source
Code: (kick.ice) [Select]
Dim server, kick
server = GetIdentifier("$icechatdir") & "servers.ini"
kick = GetIdentifier("$scriptdir") & "kick.ini"

Function f_GETPASS(channel,servernumber)
  net = getidentifier("$network",ServerNumber)
  For i=1 to GetIniFile(server,"ServerList","List",0)
    nname = GetIniFile(server,i,"Network","")
    if lcase(nname)=lcase(net) then
      n = 0
      tmp = ""
      Do while len(tmp)>0 or n=0
        tmp = getinifile(server,i,"Autojoin" & n,"")
        if left(lcase(tmp),len(channel))=lcase(channel) then f_getpass = Mid(tmp,instr(tmp,":")+1)
        n = n + 1
      loop
    End If
  Next
End Function

Function Get_Kick_Defaults(net)
enabled = GetINIFile(kick,"defaults","enabled",1)
enabled = GetINIFile(kick,net,"enabled",enabled)
delay = GetINIFile(kick,"defaults","delay",5)
delay = GetINIFile(kick,net,"delay",delay)
attempts = GetINIFile(kick,"defaults","attempts",10)
attempts = GetINIFile(kick,net,"attempts",attempts)
Get_Kick_Defaults = enabled & "," & delay & "," & attempts
End Function

Sub Rejoin(channel,servernumber)
  net = GetIdentifier("$network",ServerNumber)
  data = getinifile(kick,net,channel,"")
  if len(data)=0 then data = Get_Kick_Defaults(net)
  arr = split(data,",")
  enabled = arr(0)
  delay = arr(1)
  attempts = arr(2)
  if attempts < 1 then attempts = 1
  if enabled=1 then
    joinstr = "/join " & channel
    tmp = f_GETPASS(channel,servernumber)
    if len(tmp) > 0 then joinstr = joinstr & " " & tmp
    if delay > 0 then
      SendCommand "/timer join_" & Mid(channel,2) & " " & attempts & " " & delay & " " & joinstr,ServerNumber
    else
      SendCommand joinstr,ServerNumber
    end if
  end if
End Sub

Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
  if lcase(nickname)=lcase(GetIdentifier("$me",ServerNumber)) then Rejoin Channel, ServerNumber
End Sub

Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
  if lcase(nickname)=lcase(GetIdentifier("$me",ServerNumber)) then SendCommand "/timer join_" & Mid(channel,2) & " off",servernumber
End Sub

Installation
Press ctrl+s, click "Scripts", click File -> new, paste source. Save as "kick.ice", Note: You must save this as a .ICE file!

Configuring
By default the script will rejoin all channels on all networks when kicked after a delay of 5 seconds. it will make 10 attempts to join the channel before giving up. To change these settings make a file in the script directory ( //run $scriptdir ) called kick.ini

Below is an example configuration file.

Code: [Select]
[defaults]
enabled = 1
delay = 5
attempts = 10

[QuakeNet]
enabled = 0
#icechat = 1,30,3

Be sure to note the syntax for channels; #channel = enabled,delay,attempts. You must include all 3 parts when specifying a channel, but network defaults will inherit from global defaults.

Any questions, comments, bug reports, etc free fill to post here, or better yet drop by the #icechat support channel.
« Last Edit: September 15, 2008, 10:03:04 AM by DarkStar »
This message brought to you by the Wonderful Wizard of Oz.