Colour Defender
Platform: mIRC
Published Mar 25, 2009
Updated Mar 27, 2009
This was written up in response to a request on the forum, and then the requester suggested that I submit it as a snippet.
On a channel by channel basis (and works over multiple networks), you can set the number of lines that a person can use in colour before the script sets mode +S
Settings are stored in a hash table. Settings can be controlled via text or menu.
When using text to control the settings, you must be an op in the channel.
Warning: Original code will also be triggered by bold, underline and reverse character codes, not just colour codes. Code has been edited to allow for these extra codes.
on *:text:*:#:{
var %text = $1-
tokenize 32 $strip($1-)
if $nick isop $chan {
if $1 == !help {
.msg $nick Available commands:
.msg $nick !help -> Brings up this help.
.msg $nick !colour <on/off>
.msg $nick !color <on/off>
.msg $nick !lines <number of lines allowed>
.msg $nick !delay <time in minutes>
}
if $1 == !colour || $1 == !color {
if $istok(on off,$2,32) {
.hadd -m Colour $+($network,.,$chan) $iif($2 == on,$true,$iif($2 == off,$false))
.onotice $chan Colour Defender for $chan is now $2 $+ . Set by $nick
}
}
elseif $1 == !lines {
if $2 isnum 1- {
.hadd -m Colour $+($network,.,$chan,.Lines) $2
.onotice $chan Number of coloured lines allowed in $chan has been set to $2 by $nick
}
}
elseif $1 == !delay {
if $2 isnum 1- {
.hadd -m Colour $+($network,.,$chan,.Delay) $calc($2 * 60)
.onotice $chan Time delay to automatic removal of Colour stripping set to $2 minutes by $nick
}
}
}
if $1- != $strip(%text,c) {
.hinc -m Colour $+($network,.,$chan,.,$address)
if $hget(Colour,$+($network,.,$chan,.,$address)) >= $hget(Colour,$+($network,.,$chan,.Lines)) {
if S !isincs $chan($chan).mode {
.mode $chan +S
.timer 1 $hget(Colour,$+($network,.,$chan,.Delay)) mode $chan -S
.onotice $chan $nick activated mode +S by using $hget(Colour,$+($network,.,$chan,.,$address)) coloured lines.
}
}
}
}
menu channel {
Colour Defender
.Turn $iif($hget(Colour,$+($network,.,$chan)),Off,On) :{
.hadd -m Colour $+($network,.,$chan) $iif($hget(Colour,$+($network,.,$chan)),$false,$true)
if !$hget(Colour,$+($network,.,$chan,.Lines)) { .hadd -m Colour $+($network,.,$chan,.Lines) 2 }
if !$hget(Colour,$+($network,.,$chan,.Delay)) { .hadd -m Colour $+($network,.,$chan,.Delay) 10 }
}
.Lines $hget(Colour,$+($network,.,$chan,.Lines)) : .hadd -m Colour $+($network,.,$chan,.Lines) $?="Number of coloured lines allowed"
.Delay $hget(Colour,$+($network,.,$chan,.Delay)) : {
var %d.time = $?="Time Delay in minutes"
.hadd -m Colour $+($network,.,$chan,.Delay) $calc(%d.time * 60)
}
}
on *:start:{
if !$hget(Colour) { .hmake Colour 100 }
if $exists($qt($scriptdirColour.hsh)) {
.hload Colour $qt($scriptdirColour.hsh)
}
}
on *:disconnect:{
.hsave Colour $qt($scriptdirColour.hsh)
}
on *:exit:{
.hsave Colour $qt($scriptdirColour.hsh)
}