Topic masks allow you to enforce a pattern that all topics in your channel should follow.
To effectively make use of this handy feature, you'll need a firm understanding of how "wildcards" work, which we'll discuss in the next section of this guide.
The great Wikipedia defines a wildcard as a character that may be substituted for any of a defined subset of all possible characters. In other words, a wildcard acts as a place holder. It'll be substituted for any other character or several characters. Topic masks support two wildcards:
- * - (asterisk) - substitutes for zero or more characters
- ? - (question mark) - substitutes for zero or one character
These two wildcards operate in the same fashion as they do in DOS/Unix-like environments, as well as channel bans.
To keep things simple, we'll only be using the asterisk wildcard in this guide.
In Linux, to delete a file, you might execute the following command:
The above command would delete all files named "notes", regardless of extension. Thus, notes.png, notes.pdf, notes.html, etc. would all be deleted; therefore, the asterisk (*) wildcard simply means anything.
Setting your channel topic
Now that we understand wildcards, let's apply them to the topic mask feature. We'll start with an example:
You want to set the following topic in the channel #darenet: "Welcome to DareNET! NEWS: Follow us on Twitter @darenetirc". However, you want to able to update what follows "NEWS:" without having to retype everything that comes before it each time you change the topic with exciting new information. Topic masks make this easy, allowing you to do something like:
<trip> .topic Happy Holidays! * C changes the topic to Welcome to DareNET! NEWS: Happy Holidays!
You'll notice that only the part after "NEWS:" changed from the original topic, which was replaced with what trip typed in #darenet. This method of topic alteration is what we call topic masking. Cool, right? So how did we achieve this? By taking advantage of wildcards, specifically the asterisk (*) wildcard.
SET TOPICMASK command, you'd set the following topic mask to achieve the above:
/msg C SET #darenet TOPICMASK Welcome to DareNET! NEWS: *
Notice that we used the asterisk (*) wildcard after "NEWS:". This lets C know to allow anything here, substituting it with whatever someone supplies with the
You will need to set enforce topic to "501" if you do not want the topicmask and defaulttopic to be overridden when setting the topic.
/msg C SET #darenet ENFTOPIC 501
There is one small "gotcha" to be aware of, and that is C's topic snarf feature. C will ignore the topic mask setting whenever anyone with an access level greater than the channel's TOPICSNARF level changes the topic via /topic, replacing the entire topic. By default, this level is set to 501, which causes the topic mask setting to always be respected. If for some reason this level has been changed on your channel, you can change it by using C's
SET TOPICSNARF command.
/msg C SET #darenet TOPICSNARF 501