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 

help in caps kicker tcl for arfer
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sat Feb 10, 2018 6:21 pm    Post subject: help in caps kicker tcl for arfer Reply with quote

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

_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
SpiKe^^
Owner


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

PostPosted: Sat Feb 10, 2018 7:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sat Feb 10, 2018 8:15 pm    Post subject: Reply with quote

already probe going down and it does not work

vCapsPercentAllow 50
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
SpiKe^^
Owner


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

PostPosted: Sat Feb 10, 2018 8:20 pm    Post subject: Reply with quote

Let me point out again, those text lines above are all under 50% caps Smile
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
View user's profile Send private message Visit poster's website
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sat Feb 10, 2018 8:36 pm    Post subject: Reply with quote

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

_________________
Very Happy thanks to that they help, that others learn Very Happy


Last edited by Arnold_X-P on Sat Mar 31, 2018 6:48 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Feb 12, 2018 9:52 am    Post subject: Reply with quote

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
View user's profile Send private message
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Tue Feb 13, 2018 11:47 pm    Post subject: Reply with quote

if friend recognizes nicknames that are online
see http://forum.egghelp.org/viewtopic.php?t=17178
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sun Oct 18, 2020 9:40 pm    Post subject: Reply with quote

does not recognize or does not ignore nicknames that use capital letters..
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Oct 18, 2020 11:47 pm    Post subject: Reply with quote

Perhaps You could add another line to check for nick and caps in nick to exempt from caps checker
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Oct 19, 2020 6:06 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Oct 19, 2020 10:35 am    Post subject: Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Oct 19, 2020 11:02 am    Post subject: Reply with quote

Well, I didn't know lmap Sad 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
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Wed Oct 21, 2020 2:49 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sat Nov 07, 2020 12:06 am    Post subject: Reply with quote

[04:02:41] Tcl error [pCapsDetect]: can't read "diff": no such variable
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Nov 07, 2020 7:51 am    Post subject: Reply with quote

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
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  Next
Page 1 of 2

 
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