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.
Help for those learning Tcl or writing their own scripts.
-
ComputerTech
- Master
- Posts: 399
- Joined: Sat Feb 22, 2020 10:29 am
-
Contact:
Post
by ComputerTech »
So i was wondering how to make it a user can choose how many warnings until kicking
Code: Select all
#Badwords
set swearwords {
"*[censored]*"
"*wank*"
"*pussy*"
"*[censored]*"
}
#Time until reset warnings
set brd "30"
###########Code############
setudef flag ctswear
bind pubm - * ctswear:pub
bind ctcp - ACTION ctswear:act
proc ctswear:pub {nick host hand chan text} {
global swearwords brd
if {[channel get $chan ctswear]} {
foreach badword $swearwords {
if {[string match -nocase $badword $text]} {
incr warn +1
if {$warn($host) == "1"} {
putserv "NOTICE $nick :Warning! Do not Swear on $chan, cease immediately or else"
utimer $brd {set warn "0"}
} elseif {$warn($host) == "2"} {
utimer $brd {set warn "1"}
putserv "NOTICE $nick :Warning! Do not swear on $chan, cease immediately or else"
} elseif {$warn($host) == "3"} {
putserv "kick $nick $chan Kickbanned from $chan : Reason: Use of swear word $badword"
set warn($host) "0"
}
}
}
}
}
so like
will allow 5 of
Code: Select all
putserv "NOTICE $nick :Warning! Do not swear on $chan, cease immediately or else"
Before doing
Code: Select all
putserv "kick $nick $chan Kickbanned from $chan : Reason: Use of swear word $badword"
Any ideas and help is much appreciated
ComputerTech
-
ComputerTech
- Master
- Posts: 399
- Joined: Sat Feb 22, 2020 10:29 am
-
Contact:
Post
by ComputerTech »
Nevermind
Found a way
Code: Select all
#Badwords
set swearwords {
"*[censored]*"
"*wank*"
"*pussy*"
"*[censored]*"
}
#Time until reset warnings
set brd "30"
#max warning
set maxwarning "5"
###########Code############
setudef flag ctswear
bind pubm - * ctswear:pub
proc ctswear:pub {nick host hand chan text} {
global swearwords brd maxwarning warn
if {[channel get $chan ctswear]} {
foreach badword $swearwords {
if {[string match -nocase $badword $text]} {
incr warn($host) +1
if{![info exists warn]} {return}
if {![$warn($host) == $maxwarning]} {
putserv "NOTICE $nick :Warning! Do not Swear on $chan, cease immediately or else"
utimer $brd {incr warn($host) -1 }
} else {
putserv "kick $nick $chan Kickbanned from $chan : Reason: Use of swear word $badword"
set warn($host) "0"
}
}
}
}
}
If anyone knows of a better way of doing this, do share
EDIT: Fixed
Last edited by
ComputerTech on Fri Feb 19, 2021 3:50 pm, edited 2 times in total.
ComputerTech
-
CrazyCat
- Revered One
- Posts: 1305
- Joined: Sun Jan 13, 2002 8:00 pm
- Location: France
-
Contact:
Post
by CrazyCat »
That's the way I would do it.
Just think about two detals:
- set the warn variable global (or use ::warn)
- check if warn($host) exists before increment it (positive or negative)
-
ComputerTech
- Master
- Posts: 399
- Joined: Sat Feb 22, 2020 10:29 am
-
Contact:
Post
by ComputerTech »
Ok cheers CrazyCat, will do that right away
ComputerTech