!partall with exceptions

By R0K on Jun 25, 2010

This is just a simple script I decided to share that parts all channels except the ones that you have listed. Put this in the remotes of your bot. in the owners alias, put all the hosts that are allowed to trigger the command, separated by spaces.

I appreciate any comments and feedback.

alias blockpart { /return  }
;put the #channels that you don't want it to part separated by spaces after /return 

alias owners { /return  }
;dont forget to put the nicknames of the owners

alias  partchans { 
  /set %x $ComChan($me,0)
  while (%x) {
    /set %y $comchan($me,%x)
    if (!$istok($blockpart,%y,32)) { /part %y }
    dec %x
  } 
}

on $*:TEXT:/^[.@!]partall/Si:#: {
  if ( $istok($owners,$wildsite,32) ) { /partchans }
}

Comments

Sign in to comment.
WorldDMT   -  Jun 27, 2010

i dont understand but the code will set %c without the excluded channels

so if i set %b #chan1 #chan2 #chan3 and i'm in 5 channels %c will be set as #chan4 #chan5

 Respond  
Jethro   -  Jun 27, 2010

I did. But for some reason, it always and only parts the last channel; it doesn't matter if I've added some channels to be excluded. ;/

 Respond  
WorldDMT   -  Jun 27, 2010

you test it?

i just test it and it's work :p

 Respond  
Jethro   -  Jun 26, 2010

P.S: not testedyeah WorldDMT, that ain't gonna work correctly.

 Respond  
napa182   -  Jun 26, 2010

lol @ the list of diff ways to go about a part all or more like part some snippet...

 Respond  
WorldDMT   -  Jun 26, 2010

no i was tolking about "part chan1, chan2, chan3"

alias xpart {
  var %a 1,%b #chan1 #chan2 #chan3 #chan4
  while ($chan(%a)) var %c $iif(!$istok(%b,$v1,32),$addtok(%c,$chan(%a),44)),%a %a + 1
  part %c
}

P.S: not tested

 Respond  
Jethro   -  Jun 26, 2010

There are various ways to go about this:

(Tokenize method with regsubex loop)

alias example1 {
  var %b #chan1 #chan2 #chan3 #chan4
  tokenize 32 $regsubex($str(.,$chan(0)),/./g,$&
    $iif(!$istok(%b,$chan(\n),32),$chan(\n)) $chr(32))
  part $*
}

(WorldDMT's $addtok 44 suggestion)

alias example2 {
  var %a 1, %b #chan1 #chan2 #chan3 #chan4
  while $chan(%a) {
    var %y $v1
    if !$istok(%b,%y,32) {
      var %c $addtok(%c,%y,44)
    }
    inc %a
  }
  tokenize 44 %c
  part $*
}

(Multiple target method if your network supports it)

alias example3 {
  var %a 1, %b #chan1 #chan2 #chan3 #chan4
  while $chan(%a) {
    var %y $v1
    if !$istok(%b,%y,32) {
      var %c $addtok(%c,%y,44)
    }
    inc %a
  }
  part %c
}

(Negative loop)

alias example4 {
  var %x $chan(0), %b #chan1 #chan2 #chan3 #chan4
  while %x {
    var %y $chan(%x)
    if !$istok(%b,%y,32) { 
      part %y 
    }
    dec %x
  } 
}

(Positive loop)

alias example5 {
  var %x 1, %b #chan1 #chan2 #chan3 #chan4
  while $chan(%x) {
    var %y $v1
    if !$istok(%b,$v1,32) { 
      part %y 
    }
    inc %x
  } 
}
 Respond  
WorldDMT   -  Jun 26, 2010

u can use $addtok 44 and part all tokenized channels

 Respond  
Jethro   -  Jun 25, 2010

I know, the title should have been called or changed to "Partall with Channel Exception." This will avoid confusion.

 Respond  
sunslayer   -  Jun 25, 2010

o, i just read the title lol

 Respond  
Jethro   -  Jun 25, 2010

sunslayer, /partall command is very handy indeed, but that won't exclude you from keeping some channels you want to stay in.

 Respond  
sunslayer   -  Jun 25, 2010

/help /partall

 Respond  
Jethro   -  Jun 25, 2010

You snippet is still at risk of being taken over. If I cloned an owner's nick successfully, I could command your bot to part all the channels.

if ($istok($owners,$wildsite,32)) { <- this is still recommended.

Then add all of their hosts in your owners alias.

Again, you don't need to use /set

Using global var will set the vars and leave them behind in your variables.

Use /var instead, so the variables will get themselves unset after they finish their routines.

var %x = $ComChan($me,0)
var %y = $ComChan($me,%x)

 Respond  
R0K   -  Jun 25, 2010

Thanks, i changed it a little so that if an owner of the bot doesn't have to have the same host, but their nick needs to be in the owner alias because multiple people from different computer can be co-owners. Also, i added the /Si which i forgot to put at first :P

 Respond  
Jethro   -  Jun 25, 2010

You can just use $chan(0)
Your regex is missing > /iS without it, it won't work:

alias partchans { 
  var %x = $chan(0)
  while (%x) {
    var %y = $chan(%x)
    if (!$istok($blockpart,%y,32)) { part %y }
    dec %x
  } 
}
on $*:text:/[!@.]partall/iS:#: {
  if ($wildsite == *!*@YOURHOST) { partchans } 
}
alias -l blockpart { return #chan #chan1 #chan2 }

And you can use the local var instead of the global ones.

 Respond  
Memoli   -  Jun 25, 2010

better use

if ($wildsite == !@YOUR.HOST)

because some peoples use /cn if your nick NICK|AFK and can part your bot in all chans

 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.