| View previous topic :: View next topic |
| Author |
Message |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Feb 18, 2021 5:42 pm Post subject: Amount of Warnings before action option |
|
|
So i was wondering how to make it a user can choose how many warnings until kicking
| Code: |
#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: |
putserv "NOTICE $nick :Warning! Do not swear on $chan, cease immediately or else"
|
Before doing
| Code: |
putserv "kick $nick $chan Kickbanned from $chan : Reason: Use of swear word $badword"
|
Any ideas and help is much appreciated  _________________ ComputerTech |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Feb 18, 2021 6:16 pm Post subject: |
|
|
Nevermind
Found a way
| Code: |
#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  _________________ ComputerTech
Last edited by ComputerTech on Fri Feb 19, 2021 3:50 pm; edited 2 times in total |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Thu Feb 18, 2021 6:37 pm Post subject: |
|
|
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) _________________ 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 |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Fri Feb 19, 2021 3:21 pm Post subject: |
|
|
Ok cheers CrazyCat, will do that right away  _________________ ComputerTech |
|
| Back to top |
|
 |
|