i was wondering is there was an easier way to count the digits used in a sentence and counted untill threshold has been reached within time frame
while without having to loop thru all words in a the sentence over and over in other words if a nick wich has digits in it is mentioned the tcl should not count that
set users [split [chanlist $chan]]
set text [join [ldiff [split $text] $users]]
Note that your foreach loop stops if a nick is in the line, I don't think it's what you really want to do.
your description is exactly what i needed to check for digitts in a sentence count them even over multiple lines and if threshold within timeframe is reached to set muteban
i tried it but it doesnt seem to remove the nick from the $text
proc check:whatsapp {nick host hand chan text} {
global whatsapp
set chan [string tolower $chan]
set users [split [chanlist $chan]]
set text [join [ldiffzizo [split $text] $users "-nocase"]]
set text [string tolower $text]
set length [regexp -all {[0-9]} [stripcodes * $text]]
if {[info exists whatsapp($chan:$nick)]} { incr length $whatsapp($chan:$nick) }
if {[regexp {[0-9]{1,}} [stripcodes * $text]]} {
if {($length >= $whatsapp(maxlength))} {
set chost [getchanhost $nick $chan]
set bmask m:[maskhost "$nick!$chost" 2]
pushmode $chan +b $bmask
after [expr {1*1000*60}] [list pushmode $chan -b $bmask]
putserv "PRIVMSG $nick :you have been temporary mutebanned due to: excessive digits in your sentences"
putserv "NOTICE $nick :you have been temporary mutebanned due to: excessive digits in your sentences"
array unset whatsapp $chan:$nick
}
if {![info exists whatsapp($chan:$nick)]} {
utimer $whatsapp(unsettime) [list array unset whatsapp $chan:$nick]
}
if {[regexp {[0-9]{1,}} [stripcodes * $text]]} { set whatsapp($chan:$nick) $length }
return 0
}
}
proc ldiffzizo {list1 list2 {option -exact}} {
if {$option ne "-nocase"} { set option -exact }
return [lmap x $list1 {expr {[lsearch $option $list2 $x] < 0 ? $x : [continue]}}]
}
it seems to need exact nick while our webclient is designed if someones nick is mentioned its send like this nick:
perhaps wildcard can be used so if a nick is mentioned to check for *nick* to get the nick regardless of a character placed in front or in the back of it
heres what im working with so far the nicks removal from $text is provided by spike^^ ive integrated that it all works fine but when nicks like Guest12345 are used in the manner of :
<somenick> Guest12345: hey how are you
it counts the digits of the mentioned nick as well
set whatsapp(maxlength) 5
set whatsapp(unsettime) 20
bind pubm - * 112345check:whatsapp
proc 112345check:whatsapp {nick host hand chan text} {
global whatsapp
set nkls [chanlist $chan]
set tmptx ""
foreach word [split $text] { if {[lsearch -nocase $nkls $word] == -1} { append tmptx "$word " } }
set digitcount [regsub -all {[[:digit:]]} $tmptx "" tmptx]
putserv "PRIVMSG #test :$digitcount"
if {[info exists whatsapp($chan:$nick)]} { incr digitcount $whatsapp($chan:$nick) }
if {[regexp {[0-9]{1,}} [stripcodes * $text]]} {
if {($digitcount >= $whatsapp(maxlength))} {
set chost [getchanhost $nick $chan]
set bmask m:[maskhost "$nick!$chost" 2]
pushmode $chan +b $bmask
after [expr {5*1000*1}] [list pushmode $chan -b $bmask]
putserv "PRIVMSG $nick :you have been temporary mutebanned due to: excessive digits in your sentences"
putserv "NOTICE $nick :you have been temporary mutebanned due to: excessive digits in your sentences"
array unset whatsapp $chan:$nick
}
if {![info exists whatsapp($chan:$nick)]} {
utimer $whatsapp(unsettime) [list array unset whatsapp $chan:$nick]
}
if {[regexp {[0-9]{1,}} [stripcodes * $text]]} { set whatsapp($chan:$nick) $digitcount }
return 0
}
}
perhaps we need to add some workaround as basically issue is only with : as the network im using this on they use mibbit and mibbit tends to add postfix : if nicks are mentinoned