Auto-Join

By lol538 on Dec 30, 2009

A !ajoin script.

If you know what mIRC is then u understand it.

// !ajoin [add/del/list/activate] are the commands

Have Fun!

// !ajoin [add/del/list/activate] <channel/module>
// $2 = command, $3 = channel. [default]

on ^449:TEXT:!ajoin*:#:{
  if ($2 == add) { 
    if (!$3) { msg $chan Syntax: !ajoin add <channel> - you are doing it wrong | halt }
    if (%join.channel.if.not.exists% == true) {
      var %i 1
      while (%i <= $chan(0)) {
        if ($chan(%i) == $3) { var %cache.join xtrue }
        inc %i
      }
      if (%cache.join != xtrue) { msg $chan .. joining channel $3 | join $3 | .timer 1 3 msg $3 Heya Guys, whats up? }
    } ; type: !ajoin activate join::mode

    var %i 1
    unset %cache.chan.exists
    while (%i <= $lines(ajoin.list)) {
      if ($read(ajoin.list,%i) == $3) { set %cache.chan.exists xtrue }
      inc %i
    } ; checks if the channel was already added
    if (%cache.chan.exists == xtrue) { msg $chan I have this Channel already in my list | halt }

    write ajoin.list $3
    msg $chan Channel $3 added for autojoin!
  }
  elseif ($2 == del) {
    if (!$3) { msg $chan Syntax: !ajoin del <channel> - you are doing it wrong | halt }
    var %i 1
    while (%i <= $lines(ajoin.list)) {
      if ($read(ajoin.list,%i) == $3) { set %x-cache.chan.exists xtrue }
      inc %i
    } ; checks if the channel exists
    if (%x-cache.chan.exists != xtrue) { msg $chan The Channel: $3 isn't in my Autojoin-List. | halt }
    var %i 1
    write -c cache.txt
    while (%i <= $lines(ajoin.list)) {
      write cache.txt $remove($read(ajoin.list,%i),$3)
      inc %i
    }
    msg $chan Refresh autojoin list..
    .remove ajoin.list
    .copy cache.txt ajoin.list
    msg $chan Channel $3 was successfully removed
  }
  elseif ($2 == list) {
    var %i 1
    var %ticks-1 $ticks
    while (%i <= $lines(ajoin.list)) {
      msg $chan  %i $+ : $read(ajoin.list,%i)
      inc %i
    }
    var %ticks $calc($ticks - %ticks-1)
    msg $chan Loading autojoin list in $round($calc(%ticks / 1000)) seconds.
  }
  elseif ($2 == activate) {
    if (!$3) { msg $chan Syntax: !ajoin avtivate <module> | halt }
    if ($3 == join::mode) { set %join.channel.if.not.exists% true | msg $chan Added Module: join::mode // Joins a Channel if the Channel is added to autojoin list [type: !ajoin activate !join::mode] to deactivate | halt }
    elseif ($3 == !join::mode) { unset %join.channel.if.not.exists% | msg $chan Removing Module: join::mode | halt }
    else { msg $chan Module $3 wasnt found! :( | halt }
  }
  elseif ($2 == clear) {
    msg $chan Clearing autojoin-script - make backup..
    .remove ajoin.list.bak   
    .copy ajoin.list ajoin.list.bak
    .remove ajoin.list
    write -c ajoin.list
    msg $chan autojoin-list cleared.
  }
  elseif ($2 == help) {
    .notice $nick Autojoin-Script [c] lol538 - visit http://auktorial.com 
    .notice $nick Syntax: !ajoin add <channel> to add a channel.
    .notice $nick Syntax: !ajoin del <channel> to del a channel.
    .notice $nick Syntax: !ajoin clear to clear all channels     
    .notice $nick Syntax: !ajoin <list> to list all Channels
    .notice $nick Autojoin can used by Admins
    halt
  }
  else { msg $chan debug> you have entered $2 - [noreturn] | halt }
}
on *:CONNECT:{ .timer 1 3 do.autoconnect } ; wait 3 seconds to avoid connection pingouts.
alias -l do.autoconnect {
  var %i 1
  while (%i <= $lines(ajoin.list)) {
    join $read(ajoin.list)
    inc %i
  }
}
on ^500:TEXT:!add_user*:#:{
  ; admin-level - 500
  if (!$2) { msg $chan you need to add a username | halt }
  else { .guser 499 $2 | msg $chan Added $2 with Access 449. }
}
on ^500:TEXT:!remove_user*:#:{
  ; admin-level - 500
  if (!$2) { msg $chan you need to add a username | halt }
  else { .ruser $2 | msg $chan Removed $2 from Access List }
}
Sign in to comment.
Silo   -  Dec 31, 2009

I actually just started using Russel's script and I love it!

 Respond  
Jethro   -  Dec 30, 2009

Never mind Russel...I thought that was a broken link but it is not. lol

 Respond  
RusselB   -  Dec 30, 2009
Jethro   -  Dec 30, 2009

You can also make a while loop through the content of chanfolder of mirc.ini and make an auto join script that way, and best of all, you add all the channels you want to join in mirc's favorite list. The only difference is that's not for other people to add channels but yourself.

P.S. This is irrelevant to what your script is intended...

 Respond  
RusselB   -  Dec 30, 2009

A few things I noted in the code. 1) Unnecessary halt commands. These should be used carefully and at a minimum, as they can cause other scripts to fail. 2) The -c switch in the /write line for the clear command is redundant, since you are removing the file first. 3) I'd recommend using the -a switch in the guser command, and specify the user level in the ruser. 4) Typo in the Syntax line for the activate command. 5) In the do.autoconnect alias, use

join $read(ajoin.list,%i)

to ensure a proper connection. As it is now, the $read will get a random line, thus you could get the same line being read (and therefore joined) multiple times.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.