Auto Join Channels

By sladekraven on Mar 02, 2006

Auto Join Channels.

You can add and remove servers, when you connect to a server you auto join the channels. The channels are server specific and by that I mean if you add a server Inferno.FireServ.Za.Net for example. You can then add channels associated with that server, by clicking the server in the list first.

When the dialog closes and reopens you will probably notice the channels aren't there. Don't worry nothing has gone wrong, clicking on Inferno.FireServ.Za.Net (or other) will bring back your channels. When you add a new server please note all the channels will disappear, this is because for this server there's no channels set (server specific).. :)

I hope I explained that well enough.

alias ajoin {
  dialog $iif(!$dialog(autojoin),-dm,-ev) autojoin autojoin 
}

On *:Start: {
  hmake servers 10
  if ($isfile(autojoin\servers.dat)) {
    hload -i servers autojoin\servers.dat
    var %x = $lines(autojoin\servers.dat)
    while (%x) {
      if (*=* iswm $read(autojoin\servers.dat,%x)) {
        hmake $gettok($v2,1,61) 10
        hmake $+($gettok($v2,1,61),_chans) 10
        if ($isfile($+(autojoin\,$gettok($v2,1,61),\,chans.dat))) hload -i $+($gettok($read(autojoin\servers.dat,%x),1,61),_chans) $+(autojoin\,$gettok($read(autojoin\servers.dat,%x),1,61),\,chans.dat)
      }
      dec %x
    }
  }
}

On *:connect: {
  if (%aj.status == on) {
    if ($isfile(autojoin\servers.dat)) {
      var %x = $lines(autojoin\servers.dat)
      while (%x) {
        if (*=* iswm $read(autojoin\servers.dat,%x)) {
          if ($gettok($v2,1,61) == $server) {
            var %chans = $lines($+(autojoin\,$server,\chans.dat))
            while (%chans) {
              if (*=* iswm $read($+(autojoin\,$server,\chans.dat),%chans)) join $gettok($v2,1,61)
              dec %chans
            }
          }
        }
        dec %x
      }
    }
  }
}
dialog autojoin {
  title "Auto Join Channels by SladeKraven"
  size -1 -1 184 186
  option dbu
  combo 1, 2 3 87 100, size 
  button "Add", 2, 7 126 29 10
  box "Auto Join Status", 5, 63 144 57 20
  check "On", 6, 75 152 31 10, flat
  box "Adding/Removing Servers", 7, 4 116 70 26
  button "Remove", 8, 41 126 29 10
  box "Adding/Removing Chans", 4, 111 116 70 26
  button "Remove", 9, 148 126 29 10
  button "Add", 3, 116 126 29 10
  combo 10, 95 3 87 100, size
  button "[X]", 11, 73 170 37 12
}

On *:Dialog:autojoin:init:0: {
  if (%aj.status == on) did -c $dname 6
  if ($hget(servers)) {
    var %x = $hget(servers,0).item
    while (%x) {
      did -a $dname 1 $hget(servers,%x).data
      dec %x
    }
  }
}

On *:Dialog:autojoin:sclick:1: {
  var %x = $hget($+($did($dname,$did),_chans),0).item
  did -r $dname 10
  while (%x) {
    did -a $dname 10 $hget($+($did($dname,$did),_chans),%x).data
    dec %x
  }
}

On *:Dialog:autojoin:sclick:2: {
  if (!$isdir(autojoin)) mkdir autojoin
  var %aj.server = $did($dname,1).text
  if (%aj.server) {
    if (!$isdir($+(autojoin\,%aj.server))) mkdir $+(autojoin\,%aj.server)
    if (!$hget(%aj.server)) hmake %aj.server 10
    if (!$hget(servers)) hmake servers 10
    hadd servers %aj.server %aj.server
    did -a $dname 1 %aj.server
  }
  hsave -i servers autojoin\servers.dat
}

On *:Dialog:autojoin:sclick:3: {
  if (!$did($dname,1).sel) {
    echo -a -
    echo -a *** Please select a server from the first list to add channels to it from the second.
    echo -a *** Remember you can specify the channels to join for each different server. :)
    echo -a *** You could be joining #mIRC on Inferno.FireServ.Za.Net but when another server starts you'll join the channels you added for that server (if any).
    echo -a -  
  }
  else {
    if (!$did($dname,10)) echo Please enter a channel to add.
    else { 
      if (!$hget($+($did($dname,1),_chans))) hmake $+($did($dname,1),_chans) 10
      hadd $+($did($dname,1),_chans) $did($dname,10) $did($dname,10)
      did -a $dname 10 $did($dname,10)
      hsave -i $+($did($dname,1),_chans) $+(autojoin\,$did($dname,1),\chans.dat)
    }
  }
}

On *:Dialog:autojoin:sclick:6: {
  set %aj.status $iif($did($dname,$did).state == 1,on,off)
}

On *:Dialog:autojoin:sclick:8: {
  if ($did($dname,1).sel) {
    if ($hget($did($dname,1))) {
      hdel servers $did($dname,1)
      hfree $did($dname,1)
    }
    if ($hget($+($did($dname,1),_chans))) hfree $hget($+($did($dname,1),_chans))
    if ($isfile($+(autojoin\,$did($dname,1),\,chans.dat))) .remove $+(autojoin\,$did($dname,1),\,chans.dat)
    rmdir $+(autojoin\,$did($dname,1))
    did -d $dname 1 $did($dname,1).sel
  }
  hsave -i servers autojoin\servers.dat
}

On *:Dialog:autojoin:sclick:9: {
  if (($did($dname,1).sel) && ($did($dname,10).sel)) {
    if ($hget($+($did($dname,1),_chans))) {
      hdel $v1 $did($dname,10)
      did -d $dname 10 $did($dname,10).sel
      hsave -i $+($did($dname,1),_chans) $+(autojoin\,$did($dname,1),\,chans.dat))
    }
  }
}

On *:Dialog:autojoin:sclick:11: {
  dialog -x $dname $dname
}

Comments

Sign in to comment.
celticsoldier   -  Mar 21, 2006

It doesn\'t work for me.

 Respond  
Urza   -  Mar 02, 2006

mirc 6.17 has autojoin options in the favorites dialog :P

main thing id suggest with this is when you click add, have a prompt if they havent entered anything. i clicked it a couple times thinking it wasnt working right before i realised how it worked.

 Respond  
Nerd   -  Mar 02, 2006

errr well
was that \"uh huh\" like in \"uh huh you got that wrong... stupido\"
or like in \"uh huh i agree\"? :P

 Respond  
Gex   -  Mar 02, 2006

however i like the way u code

 Respond  
Gex   -  Mar 02, 2006

uh huh

 Respond  
Nerd   -  Mar 02, 2006

alright wait a sec...
i might misunderstand the sense of this snippet but...
isn\'t \"Perform\" the same?
you go there, select a network and add whatever you want to do when you connect to this network e.g.
/join #channel1
/join #channel2
/echo -a i connected to $network
also auth commands or other login stuff...
and the snippet will auto-join channels when you connect to a specific server (i don\'t know if that\'s a good idea... i mean there are lot of servers that belong to the same network, still the snippet is only going to join the channels if you are on ONE specific server of this network..)
i might got it wrong, but i\'m fairly sure Perform has the same functions and way more of them... therefore i really don\'t see a use for such a snippet...
maybe someone can tell me if i got that wrong..

 Respond  
sladekraven   -  Mar 02, 2006

I\'ve looked in the mIRC help file and found \"autojoin\" but how to add channels is beyond me. I couldn\'t see how to add. If mIRC\'s is server specific then ignore this but the way it\'s set up now you can have 2 channels. #mIRC is on (irc.server1.com) and #moo is on (irc.server2.com) When you join irc.server1.com uoi will join #mIRC but not #moo vice versa.

 Respond  
Gex   -  Mar 02, 2006

thanks sladekraven :) your code is nice , documentation as well and for bearruler..i dont think mirc has this function and that gives this snippets 100% functionality. wd for the author

 Respond  
bearruler   -  Mar 02, 2006

Its good, but doesnt mIRC already have this feature?

Bear

 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.