This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

counting digits and if it exceeds threshold set mute

Help for those learning Tcl or writing their own scripts.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

This is the complete updated code to this point...

Code: Select all

set whatsapp(maxlength) 5
set whatsapp(unsettime) 20

bind pubm - * 112345check:whatsapp


proc 112345check:whatsapp {nick host hand chan text} {
   global whatsapp

   set text [stripcodes c $text]
   if {![string match {*[0-9]*} $text]} {  return 0  }

   set nkls [chanlist $chan]
   set tmptx ""
   foreach word [split $text] {
      set word [string trimright $word ":"]
      if {[lsearch -nocase -exact $nkls $word] == -1} { append tmptx "$word " }
   } 
   set digitcount [regexp -all {\d} $tmptx]
   #putserv "PRIVMSG #test :$digitcount"

   if {$digitcount == 0} {  return 0  }
   if {[info exists whatsapp($chan:$nick)]} {  incr digitcount $whatsapp($chan:$nick)  }

   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
      return 0
   }

   if {![info exists whatsapp($chan:$nick)]} {
      utimer $whatsapp(unsettime) [list array unset whatsapp $chan:$nick]
   }
   set whatsapp($chan:$nick) $digitcount
   return 0
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i noticed if a nick has like [Guest]12345 and types his nick it doesnt get removed as well
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i also noticed if a nick like [Guest]12345 types like:

[Guest]12345 [Guest]12344 [Guest]12345 [Guest]12344 12

gets counted and reaches threshold while both nicks [Guest]12345 [Guest]12344 are on channel
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

simo : I don't notice any of that weirdness happening.

Load the full patched version of the script from above.
You already verified [lsearch -nocase -exact... fixed that issue.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

yes i tested using ur latest posted code spike^^ it fixed the previous issue but for some reason the latter mentioned issue i noticed as well

ive loaded it in an active channel ill monitor it and get back at ya thanks so far spike^^ and CC
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i was wondering if we could have this code check if digits only in the sentence as we seem to get a lot of false positives especially with certain emoticons with digits in them


so for example trigger on only digits in sentence else ignore

so trigger on 12345
and not on 12345dfdf or kjskjs12345

ive messed with it to try and configure it that way but it seems no matter what i try i cant get it right
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

If you want to check if a line contains only digits and spaces:

Code: Select all

regsub -all -- {[0-9\ ] $text {} textbis
if {$textbis eq ""} {
   # do your stuff
}
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Thanks CC that seems to work well

besided the missing } wich i added at :

regsub -all -- {[0-9\ ]} $text {} textbis
Post Reply