With an Action you can setup Snak to respond automatically to a
wide variety of events. An Action consists of a specified event,
like "On join" and a selected response, like "Send private message".
With actions you can:
- Greet someone that joins a channel, and inform them of the channel rules.
- Authenticate yourself to a channel service when you join a channel.
- Play a sound when a friend signs on to IRC, or sends you a message.
- Accept DCC chats from known friends.
- Accept a particular kind of files, like MP3 automatically, and save them
in a particular location.
- Open a MP3 file in iTunes after it has been received.
- Highlight messages that contain a particular word or your nick.
And much more.
Events and Responses
While you are using IRC several event may happen that require a
response from you. Actions allows you to automate responses that
you make all the time. To make an Action more specific, each event
has parameters. When the selected event happens, Snak checks to
see if the entered parameters apply. For instance, the "On join"
events are checked when someone joins a channel.
The parameters for that event consists of a channel name and a
nick. That means Snak will perform the response if the name of the
channel matches the channel name event parameter, and if the nickname
or userhost of the person matches the nick event parameter.
Whenever an event has a nick field you can use it to match on either
the nickname or the userhost of the user in question.
There are many combinations of events, parameters and responses. This allows
you to automate a wide variety of situations.
In the above example you have an Action that responds when someone called myfriend or myfriend1 joins the channel #macintosh on Undernet. When that happens Snak will send a private message to the person that just joined with the text Hi and the nickname.
Each kind of event has a set of possible responses. The "On join"
event has the most extensive response list of all the events. You can choose
to send a channel message, a private message or a notice to the nick that just
joined the channel. You can also do a whois in order to learn more about the
person, or you can run an arbitrary command, play a sound or speak a message.
One of the other events is "On signoff" which occurs when someone
from your notify list signs off IRC. This event only has three possible responses,
namely to run an arbitrary command, to play a sound or speak a message.
There are many other possible events, and the following
page describes each event, the event parameters and the possible responses.
There are some common features of event parameters that allow you to apply
a single Action in many situations.
For instance the parameters for the "On join" event can
be set in several combinations:
- To have the Action apply to everyone joining a particular channel, fill
out the channel name, and leave the nick blank.
- To have the Action apply in all channels whenever a particular nick joins,
leave the channel name blank, and fill in the nick.
- Leave both channel name and nick blank to have the Action apply to everyone
joining in all channels.
Some events, like "On channel message" also include a channel message parameter.
The same rules apply so you can leave it blank to have the action apply to all
channel messages or you can enter a text string to narrow the scope of the Action.
Matching text strings
In order to make it possible to match a parameter to more than one precise string, wildcards are used. A wildcard is a special character that stand in for other text. Snak supports three wildcards:
- '*' matches any sequence of characters.
- '%' matches any sequence of characters except a space.
- '?' matches any single character.
"% % abc" would match a message with two words and then the word "abc"
"*abc* would match any message that contains "abc"
For example, if you have an Action with an "On join"
event that has "myfriend" as the nick parameter, Snak
will only apply the Action to that specific nick. If your friend
sometimes uses the nick "myfriend[Work]" the Action will
not be applied. In order to work around that use a wildcard. For
example, use "myfriend*" to match both "myfriend"
In order to make it easier to use, Snak will automatically add a "*"
wildcard before and after a string in the message field if you haven't used
any other wildcards directly. In order to avoid this you can put quotes around
the text in the message field.
Variables and text substitution
Sometimes it is also useful to use text substitution. This means using a variable like $mynick in one of the parameters. When Snak determines if the Action applies it substitutes
the current nickname instead of $mynick.
For example, if you want to respond
to a greeting containing your nickname, enter "Hi $mynick"
in the message field for the event. This also
makes the Action continue to work when you change nick, or if you use a differenct nickname for each connection. However, if your nickname
happens to contain a wildcard character like the three above the Action will
probably not work.
The "$mynick" substitution is only active for the message field in
the event part of the Action. There are other substitutions that are active
for the response side and they are explained on the next page.