Like the title said, it count words when added to the database.
Just thought I post this as a snippet. It's a minor update to the code I posted on this thread.
Usage:
!addword
!countword
!delword
;================================================
; Word Count
; Version 1.1
; Written by: xDaeMoN
; Email: xdaemon@xdaemon.us
;
;================================================
On *:START: {
if ( !$hget($wc.table) ) hmake $wc.table 100
if ( $isfile($wc.data) ) hload $wc.table $wc.data
}
On *:EXIT: if ( $hget($wc.table) ) hsave -o $wc.table $wc.data
On *:DISCONNECT: if ( $hget($wc.table) ) hsave -o $wc.table $wc.data
alias wc.table return wordcount
alias wc.data return $qt($scriptdirwordcount.dat)
alias wc.count {
tokenize 32 $1-
if ( $hfind($wc.table,$1-,1,W) ) {
var %t = $v1
if ( $wildtok($1-,%t,0,32) ) hinc -m $wc.table %t $v1
}
}
On *:TEXT:!*word &:#: {
if ( $1 == !addword ) {
if ( !$hget($wc.table,$+(*,$2,*)) ) {
hadd -m $wc.table $+(*,$2,*)
msg $chan Added $2 in my database.
}
else msg $chan $2 is already in my database.
}
elseif ( $1 == !countword ) {
if ( $hget($wc.table,$+(*,$2,*)) ) msg $chan $2 has been said: $v1 times.
else msg $chan That word is not in my database.
}
elseif ( $1 == !delword ) {
if ( $hget($wc.table,$+(*,$2,*)) ) {
hdel $wc.table $+(*,$2,*)
msg $chan Deleted $2 from my database.
}
else msg $chan That word is not in my database.
}
}
on *:TEXT:*:#: wc.count $strip($1-)
On *:ACTION:*:#: wc.count $strip($1-)