| View previous topic :: View next topic |
| Author |
Message |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Feb 10, 2018 6:21 pm Post subject: help in caps kicker tcl for arfer |
|
|
the tcl is very good
but note that it does not recognize variants such as
HELLO PEDRO, how are you DOING
or
greetings TO ALL HELLO if
or
hi TO ALL people
·····················
the tcl only recognizes that:
HELLO
it is possible to extend the tcl so that it recognizes these variants
| Code: |
# caps.tcl
# set bot user flags to ignore text
set vCapsFlagsAllow fo
# set text length (excluding spaces) to allow without checking
set vCapsLengthAllow 8
# set maximum percentage caps allowed (calculation excludes spaces in text)
# greater than 0, less than or equal to 100
set vCapsPercentAllow 90
# set number of warnings before punishing
# integer value equal to or greater than 1
set vCapsWarnings 3
# set here the mode of punishment
# 1 == kick only (after warnings)
# 2 == kickban (after warnings)
set vCapsPunishMode 1
# time in minutes within which a warning remains valid
# even after the user is punished, passed offences remain valid for this time period
# hence a user could be punished twice for two consecutive offences
set vCapsSinTime 20
# if punishment mode 2, set here the time in minutes the ban lasts
set vCapsBanTime 10
bind PUBM - * pCapsDetect
proc pCapsDetect {nick uhost hand chan text} {
global vCapsBanTime vCapsFlagsAllow vCapsLengthAllow vCapsPercentAllow
global vCapsPunishMode vCapsSinBin vCapsSinTime vCapsWarnings
if {[botisop $chan]} {
if {![matchattr [nick2hand $nick] $vCapsFlagsAllow $chan]} {
set caps [regexp -all -- {[A-Z]} $text]
set total [string length [regsub -all -- {[\s]} $text {}]]
if {$total > $vCapsLengthAllow} {
set percent [expr {$caps * 100.0 / $total}]
if {$percent > $vCapsPercentAllow} {
set now [unixtime]
set max [expr {$now - ($vCapsSinTime * 60)}]
lappend vCapsSinBin(${nick},$chan) $now
foreach sin $vCapsSinBin(${nick},$chan) {
if {$sin >= $max} {lappend newlist $sin}
}
set vCapsSinBin(${nick},$chan) $newlist
if {[llength $vCapsSinBin(${nick},$chan)] > $vCapsWarnings} {
switch -- $vCapsPunishMode {
1 {}
2 {
pushmode $chan +b ${nick}!$uhost
flushmode $chan
timer $vCapsBanTime [list pushmode $chan -b ${nick}!$uhost]
}
default {return 0}
}
putkick $chan $nick "excess caps, you were warned"
} else {
set output "*** [llength $vCapsSinBin(${nick},$chan)] WARNING(S) *** within the last $vCapsSinTime minutes for excess caps"
putserv "PRIVMSG $chan :$nick $output"
}
}
}
}
}
return 0
}
# eof
|
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sat Feb 10, 2018 7:20 pm Post subject: |
|
|
You have set vCapsPercentAllow 90
That means the script will trigger if the text typed has 90% caps or more.
NONE of those strings it did not trigger on have 90% caps.
The script seems to be working as intended.
Lower the percent threshold if you want to trigger this script at caps percents less than 90%. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Feb 10, 2018 8:15 pm Post subject: |
|
|
already probe going down and it does not work
vCapsPercentAllow 50 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sat Feb 10, 2018 8:20 pm Post subject: |
|
|
Let me point out again, those text lines above are all under 50% caps
Except maybe the first one...
The script states "set maximum percentage caps allowed (calculation excludes spaces in text)" _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Feb 10, 2018 8:36 pm Post subject: |
|
|
thanks Spike^^
Two modifications were made with which it works wonders: set vCapsLengthAllow 4 & set vCapsPercentAllow 40
and now it recognizes the variants
HELLO PEDRO, how are you DOING
or
greetings TO ALL HELLO if
or
hi TO ALL people
| Code: |
# caps.tcl
# set bot user flags to ignore text
set vCapsFlagsAllow fo
# set text length (excluding spaces) to allow without checking
set vCapsLengthAllow 4
# set maximum percentage caps allowed (calculation excludes spaces in text)
# greater than 0, less than or equal to 100
set vCapsPercentAllow 40
# set number of warnings before punishing
# integer value equal to or greater than 1
set vCapsWarnings 3
# set here the mode of punishment
# 1 == kick only (after warnings)
# 2 == kickban (after warnings)
set vCapsPunishMode 1
# time in minutes within which a warning remains valid
# even after the user is punished, passed offences remain valid for this time period
# hence a user could be punished twice for two consecutive offences
set vCapsSinTime 20
# if punishment mode 2, set here the time in minutes the ban lasts
set vCapsBanTime 10
bind PUBM - * pCapsDetect
proc pCapsDetect {nick uhost hand chan text} {
global vCapsBanTime vCapsFlagsAllow vCapsLengthAllow vCapsPercentAllow
global vCapsPunishMode vCapsSinBin vCapsSinTime vCapsWarnings
if {[botisop $chan]} {
if {![matchattr [nick2hand $nick] $vCapsFlagsAllow $chan]} {
set caps [regexp -all -- {[A-Z]} $text]
set total [string length [regsub -all -- {[\s]} $text {}]]
if {$total > $vCapsLengthAllow} {
set percent [expr {$caps * 100.0 / $total}]
if {$percent > $vCapsPercentAllow} {
set now [unixtime]
set max [expr {$now - ($vCapsSinTime * 60)}]
lappend vCapsSinBin(${nick},$chan) $now
foreach sin $vCapsSinBin(${nick},$chan) {
if {$sin >= $max} {lappend newlist $sin}
}
set vCapsSinBin(${nick},$chan) $newlist
if {[llength $vCapsSinBin(${nick},$chan)] > $vCapsWarnings} {
switch -- $vCapsPunishMode {
1 {}
2 {
pushmode $chan +b ${nick}!$uhost
flushmode $chan
timer $vCapsBanTime [list pushmode $chan -b ${nick}!$uhost]
}
default {return 0}
}
putkick $chan $nick "excess caps, you were warned"
} else {
set output "*** [llength $vCapsSinBin(${nick},$chan)] WARNING(S) *** within the last $vCapsSinTime minutes for excess caps"
putserv "PRIVMSG $chan :$nick $output"
}
}
}
}
}
return 0
}
# eof
|
_________________
thanks to that they help, that others learn 
Last edited by Arnold_X-P on Sat Mar 31, 2018 6:48 pm; edited 2 times in total |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Feb 12, 2018 9:52 am Post subject: |
|
|
| Ideally it would check the whole sentence for percentage used instead of per word because lets say some one has a long nick in caps an some one would type; "hi AVERYLONGNICK how are you." It would trigger |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sun Oct 18, 2020 9:40 pm Post subject: |
|
|
does not recognize or does not ignore nicknames that use capital letters.. _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Oct 18, 2020 11:47 pm Post subject: |
|
|
| Perhaps You could add another line to check for nick and caps in nick to exempt from caps checker |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Mon Oct 19, 2020 6:06 am Post subject: |
|
|
You can try this:
| Code: | # caps.tcl
# set bot user flags to ignore text
set vCapsFlagsAllow fo
# set text length (excluding spaces) to allow without checking
set vCapsLengthAllow 4
# set maximum percentage caps allowed (calculation excludes spaces in text)
# greater than 0, less than or equal to 100
set vCapsPercentAllow 40
# set number of warnings before punishing
# integer value equal to or greater than 1
set vCapsWarnings 3
# set here the mode of punishment
# 1 == kick only (after warnings)
# 2 == kickban (after warnings)
set vCapsPunishMode 1
# time in minutes within which a warning remains valid
# even after the user is punished, passed offences remain valid for this time period
# hence a user could be punished twice for two consecutive offences
set vCapsSinTime 20
# if punishment mode 2, set here the time in minutes the ban lasts
set vCapsBanTime 10
# Set this to 1 to ignore nicks in lines
set vIgnoreNick 1
bind PUBM - * pCapsDetect
proc pCapsDetect {nick uhost hand chan text} {
global vCapsBanTime vCapsFlagsAllow vCapsLengthAllow vCapsPercentAllow
global vCapsPunishMode vCapsSinBin vCapsSinTime vCapsWarnings
if {[botisop $chan]} {
if {![matchattr [nick2hand $nick] $vCapsFlagsAllow $chan]} {
if {$::vIgnoreNick == 1} {
set nicks [chanlist $chan]
set text [join [ldiff [split $text] $nicks]]
}
set caps [regexp -all -- {[A-Z]} $text]
set total [string length [regsub -all -- {[\s]} $text {}]]
if {$total > $vCapsLengthAllow} {
set percent [expr {$caps * 100.0 / $total}]
if {$percent > $vCapsPercentAllow} {
set now [unixtime]
set max [expr {$now - ($vCapsSinTime * 60)}]
lappend vCapsSinBin(${nick},$chan) $now
foreach sin $vCapsSinBin(${nick},$chan) {
if {$sin >= $max} {lappend newlist $sin}
}
set vCapsSinBin(${nick},$chan) $newlist
if {[llength $vCapsSinBin(${nick},$chan)] > $vCapsWarnings} {
switch -- $vCapsPunishMode {
1 {}
2 {
pushmode $chan +b ${nick}!$uhost
flushmode $chan
timer $vCapsBanTime [list pushmode $chan -b ${nick}!$uhost]
}
default {return 0}
}
putkick $chan $nick "excess caps, you were warned"
} else {
set output "*** [llength $vCapsSinBin(${nick},$chan)] WARNING(S) *** within the last $vCapsSinTime minutes for excess caps"
putserv "PRIVMSG $chan :$nick $output"
}
}
}
}
}
return 0
}
proc ldiff {list1 list2} {
foreach element $list1 {
if { !($element in $list2) } {
lappend diff $element
}
}
return $diff
}
# eof |
Short explanation: if vIgnoreNick is setted to 1, I remove all nicks (from chanlist) in the text.
The ldiff proc is case sensitive, and I keep it like this for a simple thing:
If CrazyCat is on your channel, we have 3 options:
- user type "crazycat" => no caps, the ratio is better for him
- user type "CrazyCat" => exact match, nick is not in stats
- user type "CRAZYCAT" => he's shouting, ratio will be worst _________________ 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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Oct 19, 2020 10:35 am Post subject: |
|
|
Instead of your ldiff you can use lmap and lsearch and can make it case insensitive if you want:
| Code: |
set diff [lmap x $list1{expr {[lsearch -nocase $list2 $x] < 0 ? $x : [continue]}}]
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Mon Oct 19, 2020 11:02 am Post subject: |
|
|
Well, I didn't know lmap I'll have a look on it.
And as I said before: I intentionnaly choose a case-sensitive mode, otherwise I'd used a different approach with lsearch and not in.
BTW, gonna learn lmap, thanks a lot _________________ 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 |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Wed Oct 21, 2020 2:49 am Post subject: |
|
|
Thanks to caesar, I'd redone my functions ldiff and lintersect (need tcl8.6):
| Code: | proc ldiff {list1 list2 {option -exact}} {
if {$option ne "-nocase"} { set option -exact }
return [lmap x $list1 {expr {[lsearch $option $list2 $x] < 0 ? $x : [continue]}}]
}
proc lintersect {list1 list2 {option -exact}} {
if {$option ne "-nocase"} { set option -exact }
return [lmap x $list1 {expr {[lsearch $option $list2 $x] >= 0 ? $x : [continue]}}]
} |
Each proc uses exact search by default, put you can pass -nocase as third argument to have a case insensitive way.
My original posts:
ldiff, lintersect, wiki page _________________ 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 |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Nov 07, 2020 12:06 am Post subject: |
|
|
[04:02:41] Tcl error [pCapsDetect]: can't read "diff": no such variable _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sat Nov 07, 2020 7:51 am Post subject: |
|
|
| Code: |
# caps.tcl
# set bot user flags to ignore text
set vCapsFlagsAllow fo
# set text length (excluding spaces) to allow without checking
set vCapsLengthAllow 4
# set maximum percentage caps allowed (calculation excludes spaces in text)
# greater than 0, less than or equal to 100
set vCapsPercentAllow 40
# set number of warnings before punishing
# integer value equal to or greater than 1
set vCapsWarnings 3
# set here the mode of punishment
# 1 == kick only (after warnings)
# 2 == kickban (after warnings)
set vCapsPunishMode 1
# time in minutes within which a warning remains valid
# even after the user is punished, passed offences remain valid for this time period
# hence a user could be punished twice for two consecutive offences
set vCapsSinTime 20
# if punishment mode 2, set here the time in minutes the ban lasts
set vCapsBanTime 10
# Set this to 1 to ignore nicks in lines
set vIgnoreNick 1
bind PUBM - * pCapsDetect
proc pCapsDetect {nick uhost hand chan text} {
global vCapsBanTime vCapsFlagsAllow vCapsLengthAllow vCapsPercentAllow
global vCapsPunishMode vCapsSinBin vCapsSinTime vCapsWarnings
if {[botisop $chan]} {
if {![matchattr [nick2hand $nick] $vCapsFlagsAllow $chan]} {
if {$::vIgnoreNick == 1} {
set nicks [chanlist $chan]
set text [join [ldiff [split $text] $nicks]]
}
set caps [regexp -all -- {[A-Z]} $text]
set total [string length [regsub -all -- {[\s]} $text {}]]
if {$total > $vCapsLengthAllow} {
set percent [expr {$caps * 100.0 / $total}]
if {$percent > $vCapsPercentAllow} {
set now [unixtime]
set max [expr {$now - ($vCapsSinTime * 60)}]
lappend vCapsSinBin(${nick},$chan) $now
foreach sin $vCapsSinBin(${nick},$chan) {
if {$sin >= $max} {lappend newlist $sin}
}
set vCapsSinBin(${nick},$chan) $newlist
if {[llength $vCapsSinBin(${nick},$chan)] > $vCapsWarnings} {
switch -- $vCapsPunishMode {
1 {}
2 {
pushmode $chan +b ${nick}!$uhost
flushmode $chan
timer $vCapsBanTime [list pushmode $chan -b ${nick}!$uhost]
}
default {return 0}
}
putkick $chan $nick "excess caps, you were warned"
} else {
set output "*** [llength $vCapsSinBin(${nick},$chan)] WARNING(S) *** within the last $vCapsSinTime minutes for excess caps"
putserv "PRIVMSG $chan :$nick $output"
}
}
}
}
}
return 0
}
proc ldiff {list1 list2 {option -exact}} {
if {$option ne "-nocase"} { set option -exact }
return [lmap x $list1 {expr {[lsearch $option $list2 $x] < 0 ? $x : [continue]}}]
}
proc lintersect {list1 list2 {option -exact}} {
if {$option ne "-nocase"} { set option -exact }
return [lmap x $list1 {expr {[lsearch $option $list2 $x] >= 0 ? $x : [continue]}}]
}
putlog "Caps.tcl by arfer is loaded"
|
|
|
| Back to top |
|
 |
|