Simple Auto Join

By TokenMaster on Sep 08, 2005

FOR INSTRUCTIONS ON HOW TO USE THE SNIPPET, SEE DOWN IN THE COMMENTS PART

alias ajoin {
  if ($regex($1,/^-a$/i) == 1) {
    if ($regex($2,/[A-Z0-9]/i) == 0) { 
      !echo -a No Network specified 
      halt 
    }
    if ($regex($2,/[A-Z0-9]/i) == 1) {
      !.echo -q $regsub($2,,,%ane)
    }
    if ($regex($3-,/[A-Z0-9]/i) == 0) {
      !echo -a No Channels specified
      halt    
    }
    if ($regex($3-,/[A-Z0-9]/i) == 1) {
      var %spc = $calc($regex($3-,/\s/gi) + 1)
      if ($regex($3-,/[&%#]\S+/xig) != %spc) {
        !echo -a Channels must have one of $eval($%#,0) prefix
        halt
      }
    }
    if ($regex($3-,/[&%#]\S+/xig) == %spc) {
      if ($numtok($hget(Ajoin,$2),32) == 0) {
        .hadd -m Ajoin $2 $3-
        .echo -q $regsub($3-,/\s/g,$chr(44),%lmnop)
        echo -a Added %lmnop to $2
        unset %lmnop
        halt
      }
      elseif ($numtok($hget(Ajoin,$2),32) > 0) { 
        var %xzs = 1
        var %chsjsh = $hget(Ajoin,$2)
        while (%xzs <= $numtok($hget(Ajoin,$2),32)) {
          .hadd -m Ajoin $2 %chsjsh $+ $chr(32) $+ $3-
          .hsave -o Ajoin Ajoin.dat 
          inc %xzs
          .echo -q $regsub($3-,/\s/g,$chr(44),%lmnop)
          echo -a Added %lmnop to $2
          unset %lmnop
          halt
        }
      }
    }
  }
  if ($regex($1,/^-c$/i) == 1) {
    if ($regex($2,/[A-Z0-9]/i) == 0) { 
      !echo -a No Network specified 
      halt 
    }
    if ($regex($2,/[A-Z0-9]/i) == 1) && ($regex($3-,/[A-Z0-9]/i) == 1) {
      !echo -a Syntax : /ajoin -c <Network> 
      halt    
    }
    if ($regex($2,/[A-Z0-9]/i) == 1) && ($regex($3-,/[A-Z0-9]/i) == 0) { 
      var %exa = $iif($hfind(Ajoin,$2),$true,$false)
      if (%exa == $true) {      
        !.echo -q $regsub($2,,,%rne)
        .hdel Ajoin %rne     
        !echo -a Removed $2 from Database 
      }  
      elseif (%exa == $false) {
        !echo -a No such $2 in database
      }          
    }
  }
  if ($regex($1,/^-g$/i) == 1) {
    if ($regex($2,/[A-Z0-9]/i) == 0) {
      !echo -a No Network Specified
      halt    
    }
    if ($regex($2,/[A-Z0-9]/i) == 1) && ($regex($3-,/[A-Z0-9]/i) == 1) {
      !echo -a Syntax : /ajoin -g <network>
      halt
    }
    if ($regex($2,/[A-Z0-9]/i) == 1) && ($regex($3-,/[A-Z0-9]/i) == 0) {
      var %exa = $iif($hfind(Ajoin,$2),$true,$false)
      if (%exa == $true) {   
        !echo -a Channels from $2 :
        .echo -q $regsub($hget(Ajoin,$hfind(Ajoin,$2)),/\s/g,$chr(44),%j)
        !echo -a %j
      }
      elseif (%exa == $false) {
        !echo -a No such $2 in database
      }
    }
  }
  if ($regex($1,/^-r$/i) == 1) {
    if ($regex($2,/[A-Z0-9]/i) == 0) {
      !echo -a No Network Specified
      halt
    }
    if ($regex($3,/[A-Z0-9]/i) == 0) {
      !echo -a No Channel Specified
      halt    
    } 
    if ($regex($4-,/[A-Z0-9]/i) == 1) {
      !echo -a Syntax : /ajoin -r <Network> <Only one #channel>
      halt    
    } 
    if ($regex($3,/[&%#]\S+/xig) == 0) {
      !echo -a Channel must have $eval(&#%,0) prefix at the beginning 
      halt    
    }
    if ($regex($3,/[&%#]\S+/xig) == 1) && ($regex($4-,/[A-Z0-9]/i) == 0) {
      var %find = $findtok($hget(Ajoin,$2),$3,1,32)
      var %find2 = $deltok($hget(Ajoin,$2),%find,32)     
      .hadd -m Ajoin $2 %find2
      !echo -a Removed $3 from $2
    }
  }
  if ($regex($1,/^-d$/i) == 1) {
    if ($regex($2-,/[A-Z0-9]/i) == 1) {
      !echo -a Wrong syntax : /ajoin -d
      halt
    }
    if ($regex($2-,/[A-Z0-9]/i) == 0) {
      .hfree Ajoin
      !echo -a Deleted Auto Join Database
    }
  }
  if ($regex($1,/^-Mg$/i) == 1) {
    if ($regex($2-,/[A-Z0-9]/i) == 1) {
      !echo -a Wrong syntax : /ajoin -Mg
      halt
    }
    if ($regex($2-,/[A-Z0-9]/i) == 0) {
      var %a = 1
      !echo -s Listing Networks and Auto Join Channels ...
      !echo -s $chr(160) 
      while (%a <= $hget(Ajoin,0).item) {
        !echo -s -        
        !echo -s $hget(Ajoin,$ifmatch).item : $replace($hget(Ajoin,$hget(Ajoin,$ifmatch).item),$chr(32),$chr(44)) 
        !echo -s -       
        inc %a
      }
      !echo -s -------
      !echo -s End Of /ajoin -Mg command
      !echo -s -------
    }
  }
  if ($regex($1,/^on$/i) == 1) {
    if ($regex($2-,/[A-Z0-9]/i) == 1) {
      !echo -a Wrong syntax : /ajoin on
      halt
    }
    if ($regex($2-,/[A-Z0-9]/i) == 0) {
      set %ajoin on
      !echo -a Auto Join set to On
    }
  }
  if ($regex($1,/^off$/i) == 1) {
    if ($regex($2-,/[A-Z0-9]/i) == 1) {
      !echo -a Wrong syntax : /ajoin off
      halt
    }
    if ($regex($2-,/[A-Z0-9]/i) == 0) {
      set %ajoin off
      !echo -a Auto Join set to Off
    }
  }
  if ($regex($1-,/[A-z0-9]/ig) == 0) {
    if (%ajoin == $null) {
      echo -a Please enable or disable the Auto Join by typing /ajoin [on|off]
      halt
    }
    elseif (%ajoin != $null) {
      !echo -a Auto Join is currently  $+ $iif(%ajoin == on,Enabled,Disabled)    
    }
  }
}

on *:connect:{
  if (%ajoin == on) {
    var %nexists $iif($hget(Ajoin,$network),true,false) 
    if ($regex(%nexists,/^false$/i) == 1) {
      halt      
    }
    elseif ($regex(%nexists,/^true$/i) == 1) {
      .join $replace($hget(Ajoin,$network),$chr(32),$chr(44))
    }
  }
}

on *:start:{
  .hmake -s Ajoin 1000
  if ($isfile(Ajoin.dat)) { hload Ajoin Ajoin.dat }
}

on *:exit:{ .hsave -o Ajoin Ajoin.dat }
on *:disconnect:{ .hsave -o Ajoin Ajoin.dat }
on *:unload:{ 
  !.unset %ane
  !.unset %rne
  !.unset %j
  !.unset %ajoin
  !.unset %lmnop
}

Comments

Sign in to comment.
[85]   -  Mar 13, 2011

ripped ¢ødë

 Respond  
HassanAbbas   -  Nov 27, 2006

donot working :(

 Respond  
TokenMaster   -  Sep 08, 2005

Thanks :)

 Respond  
xDaeMoN   -  Sep 08, 2005

Scoring is anonymous. The person who gave you that score might have a reason for giving you 5.

I haven\'t tested your code yet but it looks interesting with all the regex.

 Respond  
TokenMaster   -  Sep 08, 2005

who scored me 5 then :/ ?

 Respond  
xDaeMoN   -  Sep 08, 2005

The \"
\" that I posted was referring to what you said...

\"Sry its the first time i`m using Hawkee.com. Tought you
can have spaces in instructions hehe.\"

The \"
\" is for the line spaces which is being used in html. Sorry for the confusion. Also I haven\'t scored your snippet yet.

 Respond  
TokenMaster   -  Sep 08, 2005

what ? :/
Is there a bug for getting 5 :/ omg

 Respond  
xDaeMoN   -  Sep 08, 2005

Actually yes you could by using \"
\"

 Respond  
TokenMaster   -  Sep 08, 2005

Sry its the first time i`m using Hawkee.com. Tought you
can have spaces in instructions hehe.

Auto Join Version 1.1
I may add something else in the future
Contact me on : sonata@thefragile.com
Pmsg me on mirc.net

  • Sry for my english -
    Uses :
    /ajoin -[a|r|c|g|d|Mg] [channel1 channel2 channel3 ...]
    /ajoin [on|off]
    /ajoin

Well, this is a very easy alias and it is self explanatory from the code
The /ajoin alias is able to do 9 functions

First Function

/ajoin -a <channel1 channel2 ...>

This will add a channel or channels to auto-join on the specified network
Don`t care of inputting a channel twice.. it will overwrite itself
All channels must have the # or % or & prefix before them, else you will get an error
CHANNELS MUST BE SEPARATED BY SPACES


Second Function

/ajoin -r

This will remove a #channel from a network
ONLY ONE CHANNEL AT A TIME CAN BE REMOVED


Third Function

/ajoin -c

Only Network Parameter is needed
It will clear all Auto-Join Channels on that specified network


Fourth Function

/ajoin -g

Only Network Parameter is needed
This will echo all auto-join channels in the specified network


Fifth Function

/ajoin -d

No parameters are needed
This will delete all the information for Auto-joining channels


Sixth Function

/ajoin on

Self-explanatory
This will make you join channels you added above on specified networks
when you connect to a network


Seventh Function

/ajoin off

Self-explanatory
This will disable the auto-join and you won`t join any channel automatically on any
network


Eight Function

/ajoin

No Parameters
This will tell you if Auto Join is Enabled or Disabled


Nineth Function

-
/ajoin -Mg

It Stands for MASS get (Get everyting in Database)
No Parameters
This will make you get the list of all networks in the database
and all their auto-join channels

Any problems, just private message me or email me on sonata@thefragile.com
YOU ARE FREE TO RIP AND ARRANGE THE CODE FOR YOUR OWN USE, BUT PLEASE
LEAVE CREDITS ALIVE. THANKS.

 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.