Aliases
mIRC allows you to create aliases and scripts to speed up your IRC session or to perform repetitive functions more easily. To create aliases you must know some Basic IRC commands.
Aliases can be called from the command line, from other aliases, and from popup and remote scripts. An alias cannot call itself recursively mainly because this seems to cause more problems for users than it solves.
The following examples show you how to create aliases that perform simple functions.
/gb /join #gb
If you now type /gb this is the same as typing /join #gb.
/j /join $1
We have now added a parameter string. If we type /j #gb this is the same as typing /join #gb. The $1 refers to the first parameter in the line that you supply.
/yell /me $2 $1
If you now type /yell There! Hello the action command will be /me Hello There! The number after $ specifies the number of the parameter in the string that you entered.
/jj /join $?
The question mark indicates that you should be asked to fill in this parameter. The parameter you supply will be inserted in the line at that point. So if you type /jj a dialog will pop up asking you for the channel you want to join. If you enter #gb then the final command will be /join #gb.
/jj /join #$1
the # sign indicates that the parameter you specify should be prefixed with a hash indicating that it is a channel.
/jj /join $?="Enter channel to join:"
This does the same thing but now the dialog will have the "Enter channel to join:" line displayed inside it.
/aw /away $?="Enter away message:" | /say $!
This is similar to the line above except for the addition of the $! parameter. This refers to the text you just typed into the parameter box. ie. the away message. This saves you having to type the same message twice.
/give /me gives $$1 a $$2
The double $$ means that this command will only be executed if a parameter is specified. If you specify only one parameter in the above command it will not be executed. You can also do $$?1 or $?1 which means try to fill this value with parameter one if it exists. If parameter one does notexist, ask for it. In the first case the parameter is necessary for the command to be executed, in the second case it is not.
/slap /me slaps $1 around with $2-
The $2- indicates that everything following and including parameter 2 should be appended to the command line. if you type /slap sheepy a large trout the final line will be /me slaps sheepy around with a large trout.
You can also specify $2-5 which means use only parameters 2 to 5.
/laugh /me laughs at $1's joke
Anything appended to a $ parameter is appended to the final parameter. So if in the above example we type /laugh goat the final command would be /me laughs at goat's joke.
/silly /say Hel $+ lo th $+ ere $+ !
Parameters are normally separated by a space. To make mIRC combine parameters you can use the $+ identifier. The above line will say Hello there!.
/p /part #
The # sign refers to the channel you are currently on. So if you are on channel #blah, and you type /p then mIRC replaces the # sign with #blah, and the final command is /part #blah.
/op /mode # +o $1
To op someone you can now just type /op goat instead of the whole /mode command.
/dop /mode # -ooo $1 $2 $3
You can now deop three users by typing /dop goat dog cat.
For multiple commands you should use a | character (the shifted character usually under the \ key). So to write an alias that kicks and bans someone:
/dkb /kick # $1 | /mode # +b $1
If you want greater control over the order of evaluation of identifiers, you can use the [ ] brackets. Identifiers within these brackets will be evaluated first, from left to right. You can nest brackets.
/say % [ $+ [ $1 ] ]
You can also force a previously evaluated identifier to be re-evaluated by using extra [ ] brackets.
/set %x %y /set %y Hiya! /echo [ [ %x ] ]
You can create multi-line scripts by using the { } brackets. This allows you to create an alias which performs several commands.
/poem { /msg $1 The Wendigo, the Wendigo, /msg $1 Its eyes are ice and indigo... }
The If-then-else statement You can use if-then-else statements to decide which parts of your script executes based on the evaluation of a comparison.
/number { if ($1 == 1) echo One elseif ($1 == 2) echo Two else echo Unknown number! }
This creates an alias which tests if the parameter you supplied is the number 1 or the number 2.
For more information, see the if-then-else section.
The /goto command allows you to jump from one point in a script to another point.
/number { if ($1 == 1) goto one elseif ($1 == 2) goto two else goto unknown :one echo One halt :two echo Two halt :unknown echo Unknown number! halt }
Using a goto incorrectly could lead to an infinite loop. You can break out of a currently running script by pressing Control+Break.
Note: I did not prefix the above commands with the / command prefix. This is because the command prefix is really only needed when entering a command on the command line. In scripts, all lines are assumed to start with a command, so you do not need to use the / command prefix.
Script errors can be caught by adding an :error goto point to your script. When an error occurs, the script will jump to :error and continue running. $error returns the error message.
You can reset the error with /reseterror. If you do not reset the error, it will propagate backwards to any calling aliases until an :error is found and will halt the script as usual.
Repeats a loop containing a set of commands while the expression in brackets is true.
var %i = 1 while (%i <= 10) { echo 2 %i inc %i }
The expression in brackets uses the same format as an if-then-else statement.
Multiple while loops can be embedded. You can use /break to break out of the current loop, and /continue to jump to the beginning of the loop.
The /return command halts a currently executing script and allows the calling routine to continue processing.
You can also optionally specify a return value which will be stored in the $result identifier. The $result can then be used in the calling routine.
/return [value]
The /halt command halts a script and prevents any further processing. You can use this in remote scripts to prevent mIRC from replying to normal ctcp messages, or in aliases to halt an alias, and any calling aliases, completely.
Identifiers and Variables An Identifier returns the value of a built-in mIRC variable. For example, $time would return the current time. Whenever mIRC finds an identifier in your command, it replaces it with the current value of that identifier.
For a list of identifiers, see the Identifiers section.
Variables are identifiers whose values you can create and change yourself and use later in your scripts.
For more information on variables, see the Variables section.
A custom identifier is just an alias which returns a value, and you can use that aliases name with an identifier prefix.
For example, create an /add alias such as:
add { %x = $1 + $2 return %x }
And then use it in a command:
//echo Total is: $add(1,2)
You can supply as many parameters as you want, ie. $add(1,2,...,N).
You can also use the $prop identifier to refer to your own custom properties:
add { %x = $1 + $2 if ($prop == negative) return $calc(-1 * %x) return %x }
//echo Total is: $add(1,2).negative
Note: Built-in identifiers of the same name have priority.
You can add aliases to remote scripts by using the alias prefix and then entering your alias as usual.
alias add { %x = $1 + $2 return %x }
This is the same custom identifier as above, except it uses the alias prefix.
If you specify the -l switch in the alias definition, the alias becomes accessible only by commands in the same script and invisible to the command line and other scripts.
alias -l add { %x = $1 + $2 return %x }
You can redefine function keys to perform certain commands, just like aliases. For example:
/F1 /say Hello! /sF2 /query $1 /cF3 /ctcp $1 version
The s and c prefixes for Shift key and Control key respectively.
Note: A function key will behave differently depending on the window in which it is used. For example, when using it in a query window the $1 parameter refers to the selected users nickname. If you are on a channel and the nickname listbox is active then the function key will work on the selected nicknames. If the listbox is not active, the function key will just work on the channel.
If you are executing a command from the command line ie. by typing it into an editbox, you can force mIRC to evaluate identifiers in that command by prefixing it with two // instead of one /. For example:
/echo My nickname is $me
Would print out "My nickname is $me" and would not evaluate the $me.
//echo My nickname is $me
Would print out "My nickname is somenick" if your nickname was somenick.
If you want to force a command to perform quietly ie. without printing out any information, then you can prefix it with a "." full stop. For example:
/ignore somenick
Would print out information telling you that you are now ignoring "somenick". If you do not want this information to be displayed, then you can use:
/.ignore somenick
If you want to perform a command without it being processed as an alias, you can prefix it with a ! exclamation mark.
You can add comments to your scripts by using the ; semi-colon at the start of a line, or /* and */ to enclose text.
;This is a comment
/* This is a comment */
You can place comments anywhere in a script, they are ignored during processing.
This identifier allows you to break up a single line into multiple lines which are combined when the script is performed, so you can edit long commands more easily:
longline { echo This is an example of a long $& line that has been split into multiple lines $& to make it easier to edit }
|