An join counter that counts the number of unique nicknames joining the channel. When a nick joins the channel again, it will tell them how many times they have visited the channel. This will also tell them when they last visited the channel. Now uses hash tables & Multi-server capable.
on *:START: {
hmake jcount 100
if ($isfile(jcount.dat)) hload jcount jcount.dat
}
on *:EXIT: hsave -o jcount jcount.dat
on !*:JOIN:#: {
if ( $hget(jcount,$+($network,.,$chan,.,$nick)) ) {
tokenize 32 $v1
var %t = $calc($1 + 1)
.msg $chan Welcome Back $nick $+ . Last time you joined $chan was on $2 $+ , $duration($calc($ctime - $3)) ago $+ . (Your total visits: %t $+ )
hadd -m jcount $+($network,.,$chan,.,$nick) %t $asctime(mm/dd/yyyy) $ctime
}
else {
hinc -m jcount $+($network,.,$chan,.,total.count)
.msg $chan Welcome $nick $+ ! You're visitor $chr(35) $+ $hget(jcount,$+($network,.,$chan,.,total.count)) to join $chan $+ .
hadd -m jcount $+($network,.,$chan,.,$nick) 1 $asctime(mm/dd/yyyy) $ctime
}
}
on *:START: {
hmake jcount 100
if ($isfile(jcount.dat)) hload jcount jcount.dat
.timerjcount 0 3600 hsave -o jcount jcount.dat
}
on :JOIN:#: {
var %jnick $nick, %chan $chan
if (%jnick == $me) {
if ($hget(jcount,$+($network,.,%chan))) { halt }
else {
hadd -m jcount $+($network,.,%chan) $ctime
}
}
if ($me isop %chan) {
if ($hget(jcount,$+($network,.,%chan,.,%jnick))) {
tokenize 32 $v1
var %t = $calc($1 + 1)
.notice %jnick Welcome back 12 $+ %jnick $+ ! Last time you joined 12 $+ %chan $+ was on 12 $+ $asctime($2,ddd $+ $chr(44) dd mmm yyyy - HH:nn:ss) $+ ,7 $duration($calc($ctime - $2)) ago $+ . You have joined us here 12 $+ %t $+ times. 11Thank you and have fun!
hadd -m jcount $+($network,.,%chan,.,%jnick) %t $ctime
}
else {
hinc -m jcount $+($network,.,%chan,.,total.count)
.notice %jnick Welcome 12 $+ %jnick $+ ! You're visitor No.12 $+ $hget(jcount,$+($network,.,%chan,.,total.count)) to join 12 $+ %chan since 12 $+ $asctime($hget(jcount, $+($network,.,%chan)),ddd $+ $chr(44) dd mmm yyyy - HH $+ $chr(58) $+ nn $+ $chr(58) $+ ss) $+ . 11Thank you and have fun!
hadd -m jcount $+($network,.,%chan,.,%jnick) 1 $ctime
}
}
}
on :EXIT: hsave -o jcount jcount.dat
on :START: {
hmake jcount 100
if ($isfile(jcount.dat)) hload jcount jcount.dat
.timerjcount 0 600 hsave -o jcount jcount.dat
}
on :EXIT: hsave -o jcount jcount.dat
on @!:JOIN:#: {
if ( $hget(jcount,$+($network,.,$chan,.,$nick)) ) {
tokenize 32 $v1
var %t = $calc($1 + 1)
.notice $nick Welcome back 12 $+ $nick $+ ! Last time you joined 12 $+ $chan $+ was on 12 $+ $2 $+ , $3 - $4 $+ , $duration($calc($ctime - $5)) ago $+ . You have joined us here 12 $+ %t $+ times.
hadd -m jcount $+($network,.,$chan,.,$nick) %t $asctime($ctime,ddd dd/mm/yyyy HH:nn:ss) $ctime
}
else {
hinc -m jcount $+($network,.,$chan,.,total.count)
.notice $nick Welcome 12 $+ $nick $+ ! You're visitor No. 12 $+ $hget(jcount,$+($network,.,$chan,.,total.count)) $+ to join 12 $+ $chan $+ since 12 $+ $hget(jcount, $+($network,.,$chan)) $+ .
hadd -m jcount $+($network,.,$chan,.,$nick) 1 $asctime($ctime,ddd dd/mm/yyyy HH:nn:ss) $ctime
}
}
on :JOIN:#: {
if ($nick == $me) {
if ($hget(jcount,$+($network,.,$chan))) { halt }
else {
hadd -m jcount $+($network,.,$chan) $asctime($ctime,ddd $+ $chr(44) dd mmm yyyy - HH:nn:ss)
;hadd -m jcount $+($network,.,$chan) $ctime
}
}
}
You can add a timer to save the join count every few seconds. (It'll overwrite the jcount.dat with the latest info) This way, you don't have to worry about losing it:
on *:START: {
hmake jcount 100
if ($isfile(jcount.dat)) hload jcount jcount.dat
.timerjcount 0 15 hsave -o jcount jcount.dat
}
I put it for saving every 15 seconds, but you can put any second of your choice that you see fit. The shorter the second, the frequency of saving it becomes.