egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

counting digits and if it exceeds threshold set mute
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Fri Nov 05, 2021 11:12 am    Post subject: Reply with quote

if only we could compare nicks from nicklist with the $text and if any nick is in $text with a partial wildcard of only : on the right of nick if found like nick1763: or somenick: to strip the : and send to the section that removes nicks from $text to leave the rest to gather digit count
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Fri Nov 05, 2021 11:17 am    Post subject: Reply with quote

Ok, that's not the same proc than before, you change the way it works.

But why don't you keep the regsub given by SpiKe^^ (or mine, they are quite the same) to just clean $text of non-alphanum chars ?
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Fri Nov 05, 2021 11:37 am    Post subject: Reply with quote

Code:

set nkls [chanlist $chan]
set tmptx ""
set text [stripcodes c $text]
foreach word [split $text] {
  set word [string trimright $word ":"]
  if {[lsearch -nocase $nkls $word] == -1} { append tmptx "$word " }
}
set digitcount [regsub -all {[[:digit:]]} $tmptx "" tmptx]


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Fri Nov 05, 2021 12:38 pm    Post subject: Reply with quote

tested that last code u posted spike^^ and it seems to do exactly what we had in mind ill test some more thanks so far
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Fri Nov 05, 2021 12:48 pm    Post subject: Reply with quote

CrazyCat wrote:
Ok, that's not the same proc than before, you change the way it works.

But why don't you keep the regsub given by SpiKe^^ (or mine, they are quite the same) to just clean $text of non-alphanum chars ?


because many web clients like mibbit , irccloud and perhaps others that postfix mentioned nicks with a : making it no longer correspond with the nicks in the gathered nicklist and therefor not removed and counted with the digits having it triggering a lot of false alarms

thanks CC much apreciated as always
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Nov 06, 2021 9:29 pm    Post subject: Reply with quote

Tested it some more in an active channel and got no false alarms it seems to do exactly as expected excellent work

Thank spike^^ and cc much appreciated
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Nov 07, 2021 10:09 am    Post subject: Reply with quote

I like this slightly cleaned up version.
Code:

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
}



=> NOTE: This code has been update to reflect the fix below:) <=
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.


Last edited by SpiKe^^ on Mon Nov 08, 2021 11:16 am; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Nov 07, 2021 11:06 am    Post subject: Reply with quote

Tested this and it doesn't seem to trigger and no errors
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Nov 07, 2021 11:14 am    Post subject: Reply with quote

when i replaced
set digitcount [regexp -all {/d} $tmptx]


with :
set digitcount [regsub -all {[[:digit:]]} $tmptx "" tmptx]

it seems working again
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sun Nov 07, 2021 12:05 pm    Post subject: Reply with quote

Little typo from SpiKe^^. It's \d and not /d Smile
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Nov 07, 2021 12:18 pm    Post subject: Reply with quote

oh yea true didnt see that, that seemed to fix it thanks CC
and thanks spike^^ for the cleanup of the code
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Nov 07, 2021 12:42 pm    Post subject: Reply with quote

Ooops.

Thanks for the fix CrazyCat and simo.

Edited the above post to reflect that fix...
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Nov 08, 2021 9:17 am    Post subject: Reply with quote

i found another bug for example if a nick [Guest]12345 is on channel
and gets typed its not removed from $text and gets counted with the digits
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Mon Nov 08, 2021 9:53 am    Post subject: Reply with quote

Try replacing this line in the script...
Code:
if {[lsearch -nocase $nkls $word] == -1} { append tmptx "$word " }

with this updated line...
Code:
if {[lsearch -nocase -exact $nkls $word] == -1} { append tmptx "$word " }

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Nov 08, 2021 10:22 am    Post subject: Reply with quote

that seems to have fixed it thanks spike^^
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber