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 

multi lines max text length within time frame
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Mon Jun 15, 2020 3:15 pm    Post subject: multi lines max text length within time frame Reply with quote

i was wondering if this could be modified to count the total text length per line to some up a total within a time frame and set ban if threshold is reached:

Code:

bind pubm - * Text:Bytes

set longline(txt_len) 300

proc Text:Bytes {nick uhost hand chan txt} {
  if {![botisop $chan] || [isbotnick $nick] || [isop $nick $chan] || [matchattr $hand b] || [matchattr $hand f|f $chan] || [matchattr $hand mo|mo $chan]} {
    return
  }
  if {[string length $txt] >= $::longline(txt_len)} {
    putquick "MODE $chan +b [maskhost $uhost 2]"
  }
}


i found this somewhere not sure where tho wether forum or archives
most tcls available use per line checking text length unlike multiple lines we
look for

like for example 300:3 300 chars within 3 sec


Last edited by simo on Fri Jun 19, 2020 6:19 pm; edited 4 times in total
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Mon Jun 15, 2020 3:24 pm    Post subject: Reply with quote

oh i found author :

Long Text Protection (v1.3) by fyre
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Tue Jun 16, 2020 8:16 am    Post subject: Reply with quote

i havent found a single tcl that counts text chars and gets a total within a time threshold and chars value threshold
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Tue Jun 16, 2020 11:06 am    Post subject: Reply with quote

this is an msl variant of it stripped from color/bold/underlined codes:

Code:

ON ^*:text:*:#:{
    if ($nick(#,$me,@&~%) && !$nick(#,$nick,@&~%)) {
      inc -u5 %bytes. [ $+ [ $site ] $+ ] . [ $+ [ $chan ] ]  $calc($regex($1-,/\S/gSu) + 50)
      if (%bytes. [ $+ [ $site ] $+ ] . [ $+ [ $chan ] ] >= 300) {  ban -k $chan $nick 4  Bytes Flood }
  }
}


the added + 50 in calculation part is to counter the evading by staying under the limit in some cases when spamming slow and using view chars
Back to top
View user's profile Send private message
grumpy
Voice


Joined: 10 Jan 2014
Posts: 9
Location: Europe/London

PostPosted: Thu Jun 18, 2020 1:25 pm    Post subject: Reply with quote

Code:
% string bytelength
wrong # args: should be "string bytelength string"
% string bytelength "teststring"
10
%


https://www.tcl.tk/man/tcl8.3/TclCmd/string.htm#M5

Maybe something like the following
Arrow dont need to check for isbotnick

Code:

set byte_flood 300

bind pubm - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {
 global byte_flood
 # if the bots not opped, we dont do anything
 if {![botisop $chan]} {return}
 # if its a channel op exempt them
 if {[isop $nick $chan]} {return}
 # if its a validuser and they have +b or +fmo|fmo flags exempt them
 if {([validuser $hand]) && ([matchattr $hand bfmo|fmo $chan])} {return}
 if {([string bytelength $string] == $::byte_flood)} {
  putserv "MODE $chan +b [maskhost "$nick!$host" 2]"
  return
 }
}
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Thu Jun 18, 2020 1:32 pm    Post subject: Reply with quote

thnx grumpy i tried it and it returns this error:

Tcl error [pubm:byteflood]: can't read "string": no such variable

and also this seems to only count in 1 line and not count total sent lines to reach threshold :


if {([string bytelength $string] == $::byte_flood)} {
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Thu Jun 18, 2020 1:46 pm    Post subject: Reply with quote

this works but it doesnt count total used chars from multiple lines to get end result and compare against threshold for example 300:5 300 or more chars used within 5 secs

Code:

set byte_flood 300

bind pubm - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {
 global byte_flood
 # if the bots not opped, we dont do anything
 if {![botisop $chan]} {return}
 # if its a channel op exempt them
 if {[isop $nick $chan]} {return}
 # if its a validuser and they have +b or +fmo|fmo flags exempt them
 if {([validuser $hand]) && ([matchattr $hand bfmo|fmo $chan])} {return}
 if {([string bytelength $text] >= $::byte_flood)} {
 if {[isvoice $nick $chan]} {  pushmode $chan -v $nick }
  pushmode $chan +b [maskhost "$nick!$host" 2]
 }
}


this is somewhat the same as i posted in the first post
Back to top
View user's profile Send private message
grumpy
Voice


Joined: 10 Jan 2014
Posts: 9
Location: Europe/London

PostPosted: Thu Jun 18, 2020 8:37 pm    Post subject: Reply with quote

Not really sure about the error, I kind of just wrote an example of using string bytelength while replying Embarassed

Maybe add a utimer unset for 5 seconds? and keep a byte count against the hostmask, so when they go over the limit they get banned. Confused

Code:
set byteflood(count) 300
set byteflood(time) 5

bind pub - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {
 global byteflood
 if {(![botisop $chan]) || ([isop $nick $chan]) || ([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}
 set bytes [string bytelength $text]
 set mask [maskhost "$nick!$host" 2]
 if {[info exists ::byteflood($mask)]} {
  set ::byteflood($mask) [expr {$::byteflood($mask) + $bytes}]
  if {($::byteflood($mask) > $::byteflood(count))} {
   putquick "MODE $chan +b $mask"
   unset ::byteflood($mask)
   return
  }
  utimer $::byteflood(time) "unset ::byteflood($mask)"
  return
 } else {
  set ::byteflood($mask) $bytes
  utimer $::byteflood(time) "unset ::byteflood($mask)"
  return
 }
}
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Fri Jun 19, 2020 7:33 am    Post subject: Reply with quote

tested it grumpy it doesnt seem to work as nothing happens and i dont get anhy errors in PL

also im not sure about that variable what would happen if 2 or more users with different IPS type text whos would it count ?

perhaps it should have channel and nick!user@host atached to the variable so it counts for each nick seperate just like the one i posted for msl

and after reading about bytes in docs it seems different from text length perhaps in this case we should use text length rather than bytes
Back to top
View user's profile Send private message
grumpy
Voice


Joined: 10 Jan 2014
Posts: 9
Location: Europe/London

PostPosted: Fri Jun 19, 2020 8:27 am    Post subject: Reply with quote

Yeah, i don't think bytelength is what your looking for

Code:
[13:21:00] <+afk-dead> this is going to be over 200 lines of text hopefully? thought am not sure how long the line needs to be to trigger a bytes flood or not. Maybe just keep typing and see what happends? thats usually the best way?
[13:21:01] <@eggie> Bytes Count. 210
[13:21:23] <+afk-dead> thisisgoingtobeover200linesoftexthopefully?thoughtamnotsurehowlongthelineneedstobetotriggerabytesfloodornot.Maybejustkeeptypingandsee whathappends?thatsusuallythebestway?
         [ didn't trigger without spaces ]
         [ note i set it trigger on over 200 bytes ]
[13:21:37] <+afk-dead> thisisgoingtobeover200linesoftexthopefully?thoughtamnotsurehowlongthelineneedstobetotriggerabytesfloodornot.Maybejustkeeptypingandsee whathappends?thatsusuallythebestway?thisisgoingtobeover200linesoftexthopefully?thoughtamnotsurehowlongthelineneedstobetotriggerabytesfloodornot.Maybejustkeeptypingandsee whathappends?thatsusuallythebestway?
[13:21:38] <@eggie> Bytes Count. 340

[13:24:21] <+afk-dead> .tcl info patchlevel
[13:24:21] <@eggie> OK: 8.6.9 - 0.115 ms
Back to top
View user's profile Send private message
grumpy
Voice


Joined: 10 Jan 2014
Posts: 9
Location: Europe/London

PostPosted: Fri Jun 19, 2020 8:42 am    Post subject: Reply with quote

Code:
set bflood(maxlength) 300
set bflood(unsettime) 5

bind pub - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {
 global bflood

 # ignore if bot not opped, ignore if its a chanop, ignore if the user has +bfmo globally or +fmo for the channel
 if {(![botisop $chan]) || ([isop $nick $chan]) || ([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}

 # get the length of the text
 set length [llength $text]

 # ban mask
 set bmask [maskhost "$nick!$host" 2]

 # look up if we have them already
 set nick [string tolower $nick]
 set chan [string tolower $chan]
 if {[info exists ::bflood($chan:$nick)]} {

  # increase the count by current length of text
  set ::bflood($chan:$nick) [expr {$::bflood($chan:$nick) + $length}]

  # check they haven't gone over the limit
  if {($::bflood($chan:$nick) > $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # unset from array
   unset ::bflood($chan:$nick)

   # finished
   return
  }

  # they haven't gone over the limit, lets set a timer
  utimer $::bflood(unsettime) "unset ::bflood($chan:$nick)"

  # finished
  return

 # they are within the time limit
 # we start again
 } else {
  # add them
  set ::bflood($chan:$nick) $length

  # set a time limit on them
  utimer $::bflood(unsettime) "unset ::bflood($chan:$nick)"

  # finished
  return
 }
}


This will keep a line count going for them per channel against each nickname,
if they go over 'bflood(maxlength)' total text length in 'bflood(unsettime)' seconds.

They will be banned/an devoiced if they are +v Embarassed i put comments on for you,

you should really play around it with and find out what works for you Idea
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Fri Jun 19, 2020 9:19 am    Post subject: Reply with quote

tnx again grumpy for the reply i tried your last posted code and nothing seems to happen and no errors in PL
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Fri Jun 19, 2020 10:01 am    Post subject: Reply with quote

I'm affraid you don't use utimer as you must:
Code:
utimer $::bflood(unsettime) [list unset ::bflood($chan:$nick)]

Another point: why do you do "global bflood" if you use "::bflood" in proc ?
_________________
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
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Fri Jun 19, 2020 11:25 am    Post subject: Reply with quote

ive tried this but still nothing happens and no errors in PL:



Code:

set bflood(maxlength) 300
set bflood(unsettime) 5

bind pub - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {
 global bflood

 # ignore if bot not opped, ignore if its a chanop, ignore if the user has +bfmo globally or +fmo for the channel
 if {(![botisop $chan]) || ([isop $nick $chan]) || ([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}

 # get the length of the text
 set length [llength $text]

 # ban mask
 set bmask [maskhost "$nick!$host" 2]

 # look up if we have them already
 set nick [string tolower $nick]
 set chan [string tolower $chan]
 if {[info exists bflood($chan:$nick)]} {

  # increase the count by current length of text
  set bflood($chan:$nick) [expr {$bflood($chan:$nick) + $length}]

  # check they haven't gone over the limit
  if {($bflood($chan:$nick) > $::bflood(maxlength))} {

   # they have gone over the 'maxlength'
   # devoice them if they are +v
   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   # set the ban
   putquick "MODE $chan +b $bmask"

   # unset from array
   unset bflood($chan:$nick)

   # finished
   return
  }

  # they haven't gone over the limit, lets set a timer
  utimer $::bflood(unsettime) [list unset bflood($chan:$nick)]
  # finished
  return

 # they are within the time limit
 # we start again
 } else {
  # add them
  set bflood($chan:$nick) $length

  # set a time limit on them
  utimer $::bflood(unsettime) [list unset bflood($chan:$nick)]
  # finished
  return
 }
}
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Fri Jun 19, 2020 4:01 pm    Post subject: Reply with quote

i tried again and been gettin this error:

Tcl error in script for 'timer104056':
can't unset "bflood(#test:knowles)": no such element in array


using this so far:


Code:

set bflood(maxlength) 300
set bflood(unsettime) 5

bind pubm - * pubm:byteflood

proc pubm:byteflood {nick host hand chan text} {
 global bflood

 if {(![botisop $chan]) || ([isop $nick $chan]) || ([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}

 set length [llength $text]

 set bmask [maskhost "$nick!$host" 2]

 set nick [string tolower $nick]
 set chan [string tolower $chan]
 if {[info exists bflood($chan:$nick)]} {

  set bflood($chan:$nick) [expr {$bflood($chan:$nick) + $length}]

  if {($bflood($chan:$nick) > $::bflood(maxlength))} {


   if {[isvoice $nick $chan]} {pushmode $chan -v $nick}

   putquick "MODE $chan +b $bmask"

   unset bflood($chan:$nick)

  }

  utimer $::bflood(unsettime) "unset bflood($chan:$nick)"

 } else {
  set bflood($chan:$nick) $length

  utimer $::bflood(unsettime) [list unset bflood($chan:$nick)]
 }
}
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 -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 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