Note: The mainteinance of the scripting examples is discontinued since I no longer have an interest to continue doing so. The pages will remain here, for now, but that might not be the case in the future. You are free to download all the material on these pages and set a up mirror, or even continue the maintenance of the material by enhancing the examples yourself.

All the material in these examples are for the mIRC version 6.03. It is very likely that some or most of these examples won't work in future versions.

Simple channel moderation: dealing with colors, swearing, and public aways

The simplest channel moderation scripts act on simple triggers and do a simple action. Example of such a script would be to react to a swear word by kicking the user from the channel. Other common examples include reacting to colors and public away messages.

Normal channel messages can be reacted with on TEXT events. Actions can be reacted with on ACTION events. It's also possible to send notices to the channel which would be reacted with on NOTICE events. Public notices are very rare since they are mostly for automations. The matchtext field accepts wildcards.

If you want to react on the text manipulation control codes, like color and bold, you need to understand how the control codes are transmitted. The method is very easy. Whenever there is ASCII 2 in the message, everything after it will be bold. Whenever there is another ASCII 2, everything will be normal again. The same applies for underline and reverse except that underline is ASCII 31 and reverse ASCII 22. ASCII 15 clears all formatting. The most controversial control code is ASCII 3 which is used for colors. Colors are transmitted by sending ASCII 3 followed by the color number (0-15) which is followed by a comma and another number (0-15) for the optional background color. Reacting to these control codes is rather easy. If a line contains $chr(2), it has bold. If a line contains $chr(3), it has color. If a line contains $chr(31), it has underline etc.

Reacting to colors rarely causes any disagreements assuming that people agree on a no-color rule. However reacting to swearing or other special words often causes more disagreements because people are different. Some use such language every day while others never do it. It might also be argued that bad language and insults are better dealt with manual moderation by active operators. On the other hand a dumb script is less likely to cause favoritism or subjective decisions. The most important thing is that the channel operators listen to users and work in a way that is satisfactory for the channel regulars. People get very annoyed if they are kicked accidentally by a badly made script.

It's a fact that what might be appropriate on a small channel often is not appropriate on a big channel. The best example of such behavior are public away actions. If everyone on a channel with 50 or more users announced when they go away and back, that would be the primary content of the channel instead of actual discussion. Since the actions are just normal actions, it's not possible to do a bulletproof detection mechanism. Triggering for words "away", "back", and "gone" should be enough for most of the cases. Naturally they will also trigger when someone says they're listening to Backstreet Boys. If you decide to use this kind of script, you will probably kick people accidentally sometimes. Note that it's best to use $strip to remove the control codes when checking for the words because otherwise the script wouldn't trigger if there are control codes inside the words.

Example script

; Kick people using colors on #chat
on @*:TEXT:$(* $+ $chr(3) $+ *):#chat: kick $chan $nick No colors!
on @*:ACTION:$(* $+ $chr(3) $+ *):#chat: kick $chan $nick No colors!

; Notice people using bold on #idle
on @*:TEXT:$(* $+ $chr(2) $+ *):#idle: .notice $nick Don't use bold on #idle!
on @*:ACTION:$(* $+ $chr(2) $+ *):#idle: .notice $nick Don't use bold on #idle!

; Devoice people saying 'crap' or 'damn' on #stars
on @*:TEXT:*crap*:#stars: mode $chan -v $nick
on @*:TEXT:*damn*:#stars: mode $chan -v $nick
on @*:ACTION:*crap*:#stars: mode $chan -v $nick
on @*:ACTION:*damn*:#stars: mode $chan -v $nick

; Kick and ban people announcing away as an action on #mirc
on @*:ACTION:*:#mirc: {
  if ( (away isin $strip($1-)) || (back isin $strip($1-)) || (gone isin $strip($1-)) ) {
    ; Set the ban for five minutes
    ban -u300 $chan $nick 3
    kick $chan $nick Public away messages are not welcome
  }
}

Last updated 2003-04-05, Janne 'Geetee' Nikula, jn-mirc@zkelvin.net