Part Message And Counter

By AnaBotNowYourGone on Jun 09, 2010

When someone parts this will say a message and tell the number of people that have parted. Have fun. :)

on *:PART:#:/inc %Counter | /msg $chan Everyone, $nick has partted. He/she is number %counter to leave the channel.

Comments

Sign in to comment.
Jethro   -  Jun 10, 2010

Bielie, I don't know where you get the idea for the quit event with a # prefix to it. There's no $chan in the quit event. You either need to put the #chan by itself or loop through the $comchan:

on !*:part:#:{
  inc $+(%,p,#,$nick)
  inc $+(%,p,$nick)
  msg # $($+(%,p,$nick),2) has parted # $+ .  $&
    $nick has parted $iif($($+(%,p,#,$nick),2) = 1,$v1 time.,$v1 times.)
}
on !*:quit:{
  var %q $comchan($nick,0)
  while (%q) {
    if $me ison $comchan($nick,%q) {
      inc $+(%,q,$v2,$nick)
      inc $+(%,q,$nick)
      msg $v2 $($+(%,q,$v2,$nick),2) has parted $v2 $+ .  $&
        $nick has quit $iif($($+(%,q,$v2,$nick),2) = 1,$v1 time.,$v1 times.)
    }
    dec %q
  } 
}
 Respond  
Bielie   -  Jun 10, 2010
on *:part:#:{ 
inc %part [ $+ [ $chan ] ] 
inc %part1 [ $+ [ $nick ] ] 
msg # %part [ $+ [ $chan ] ]  people have parted $chan $+ . $1 Parted %part1 [ $+ [ $nick ] ] times.
halt
}
on *:quit:#:{ 
inc %quit [ $+ [ $chan ] ] 
inc %quit1 [ $+ [ $nick ] ] 
msg # %quit [ $+ [ $chan ] ]  people have quited $chan $+ . $1 Quited %quit1 [ $+ [ $nick ] ] times.
halt
}

I found this one on one of my old bots.

 Respond  
PATX   -  Jun 09, 2010

Don't IRC clients already do this? Not sure if I am thinking of the same thing...

Can't rate/comment until I know this...

 Respond  
Jethro   -  Jun 09, 2010

You overlooked a couple of factors:

  1. You don't want to count the client that runs the code by adding an exclamation mark in front of that part event.

  2. If the same person parts repeatedly, it'll keep on counting. You should use a dynamic variable to identify who has parted and count the time exclusively for that user.

In fact, I think it's best to use hash tables for the counting task:

on *:start:loadcounter
on *:connect:loadcounter
on *:exit:hsave -o counter counter.hsh
on *:disconnect:hsave -o counter counter.hsh
alias -l loadcounter {
  if $isfile(counter.hsh) && !$hget(counter) { 
    hmake counter 100
    hload counter counter.hsh 
  }
}
on !*:part:#:{
  hinc -m counter $nick
  msg # Everyone, $nick has partted the $ord($hget(counter,$nick)) time!
}
 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.