What’s miRC Scripting Language (MSL)?

Gen 18

The mIRC scripting language, abbreviated as MSL, is the scripting language embedded in mIRC, a popular IRC client for Windows.

Primary uses:

  • Channel and personal protection against any types of attacks (flooding, spamming, CTCP floods, etc)
  • Dialog windows can be created in mIRC to better serve user-compatibility.
  • Popular mIRC dialog extensions include MDX (Mirc Dialog Extension) and DCX (Dialog Control Extension) There are also a few versions of mdx.dll and dcx.dll modded by irc hackers.
  • Bots that provide automated IRC channel management, trivia or other games, and other desired functions for chatters.
  • Commands that save typing or otherwise simplify life on IRC (such as automatically identifying as the owner of a nickname).

Script storage:

Scripts are stored as either plain text files, usually with a .mrc file extension, or as INI files. They however can be stored with any extension. It can be: .exe, .script, etc. Multiple script files can be loaded at one time, although in some cases, one script will conflict with another and cause one or both of them to no longer work properly.

Language features:

mIRC scripting involves a peculiar nomenclature that is not entirely consistent with most of the rest of the programming world. (Most notably, the term identifier—which in most languages refers to the name of a variable or function (whether it returns a value or not)—in mIRC refers specifically to a value returning function.)

  • Built-in functions are termed commands or, if they return a value, identifiers.
  • Custom scripted functions are called aliases. Aliases that return a value are known as custom identifiers. Both are called from the command line or other parts of a script in the same ways as built-in commands and identifiers (and can even supersede them).
  • Popups are scripted context menu items. Popups are called when they are selected by the user. The term originally referred to the menus—which pop up upon a right click. It is still used this way in the manual. But the user community (who tend not to read scripting manuals) took to calling the individual items popups—perhaps thinking of the colourful novelty actions that are popular with many users as pages of a popup book.
  • Remotes are event-handling scripts. Remotes are called when the event they handle occurs. (Rule #1 for remotes are, if the 1st script in your remotes does not work, then none of the ones after that will either, so delete it if it doesn’t work)
  • All variables are dynamically typed.
  • mIRC scripts make use of sigils. Identifiers (whether custom or built-in) are preceded by $, binary variables are preceded by &, and other variables (whether local or global) are preceded by %. Commands and aliases are not preceded by any particular character (although when entered from a window’s command line they must be preceded by the command prefix, usually /).

Code examples:

The code below is in the remote scripts format. If placed into an alias file, the command names should not be preceded by the word “alias”. Test Comments include the common /* comment */ and ;comment.

Here is an example of a Hello World alias:

1
2
3
4
5
6
7
8
9
10
;Defines the alias 'hello' in the remote script
 
;Note: if this is placed in an alias script, the 'alias' part must be removed (result: hello {)
;Usage: /hello
alias hello {
 
  ;Displays(/echo) 'Hello World!' into the active window(-a)
  echo -a Hello World!
 
}

Counting to 10:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
alias ten {
 
  ;'%i' is locally set as 1
  var %i = 1
 
  ;The while loop continues until '%i' is greater than 10, then stops.
  while (%i < = 10) {
 
    ;Displays(/echo) '[value of %i]' into the active window(-a)
    ;'[value of %i]' will be 1 at the beginning of the execution.
    echo -a %i
 
    ;To continue the while loop, '%i' must be increased, or you'll
    ;have yourself an infinite loop (can be broken with Ctrl+Pause/Break)
    inc %i
 
    ;Don't forget to close the while loop scope.
  }
}

A remote script event handler:

1
2
3
4
5
6
7
;Placed in a remote script.
 
;Literally: when any user joins #IRCHelp, message to the channel: Hello [nickname that joined]
on *:JOIN:#IRChelp: { msg $chan Hello $nick }
 
;To do this for any channel, the code would be:
on *:JOIN:#: { msg $chan Hello $nick }

A remote script to automatically respond to certain text

1
2
3
4
5
6
7
;Placed in a remote script
 
;When a user types Hello! in a channel, you answer back: Hello, [nickname]!
on *:TEXT:Hello!:#:{ msg $chan Hello, $nick $+ ! }
 
;When a user types Hello! in a private message, you answer back: Hello, [nickname]!
on *:TEXT:Hello!:?: { msg $nick Hello, $nick $+ ! }