Jump to content
chain

Aliases

Recommended Posts

  • Administrators

Aliases

Aliases are mIRC's way to define functions.
An alias is a shortcut for often-used command such as join, part, quit, opping and deopping, and whatever else you want. For example:

Typing /j #channel makes you join #channel, in case that the /j was made as a shortcut for joining channel then you can call this as an alias named /j. And typing /p #channel makes you leave the channel #chanel, in case that the /p was made as a shortcut for leaving/ parting channel then you can call this as an alias named /p and so on. see this captured codes taken from the Aliases tab section in the scripts editor:

aliastabsection.gif

As you can see from the given screenshot there are some other names written as /op, /dop, /k ect... They are examples of the aliases.

Tips/ info:

  1. The written text you see after an alias name is the contained command(s) that will be executed when the related alias is triggered.
  2. An alias may contain more than one contained command.

In general, all commands which can be used in the edit box (the line or lines you normally use to talk/type in) can be used in an alias. Aliases can also be used to execute several commands at once.

Creating Aliases

Creating a new alias is relatively easy!. There are some ways to write your own aliases, and the simple one is to use the Aliases tab section in the Scripts editor. Follow the following steps to create you first alias using this way :

  1. On the main windows of your mIRC program go to Tools menu > Scripts Editor. The mIRC Scripts Editor will start with the Remote tab section opened. Select the Aliases tab section.
  2. In the Aliases editor write the following codes :

    /myfirstalias /echo This is my first alias

    When you've finished writing the codes your Aliases editor would look something like :

    aliastabsectionmyfirstalias.gif

    Press the OK button to save your aliases.
  3. Now, in the EditBox (the line or lines you normally use to talk/type in) of your mIRC type : /myfirstalias and press "Enter" on your keyboard. Congratulations!.

    If you did everything correctly you should see something like this :

    myfirstaliasdone.gif
     

Now let me explain what we did exactly. We created an Alias named myfirstalias contains a /echo command. As we can see from the result this command prints our text This is my first alias. Easy right?.

Tips/ Info:

  1. The basic syntax to write an alias in the Aliases editor is :   alias_name contained_command(s) .
  2. The forward slashes (/) before the name of the Alias and the Command are optional. Where myfirstalias echo This is my first alias without / (the forward slashes) will do the same thing as /myfirstalias /echo This is my first alias with the forward slashes (/)
  3. You can use the {} brackets to create a multi-command lines for an alias. So that You can make your "myfirstalias" alias something like:

    /myfirstalias {
    echo this is the result of the first contained command
    echo this is the result of the second contained command
    echo this is the result of the third contained command
    echo this is just another result of another command
    echo Now I understand that I can use {} brackets to create a multi command lines for my alias
    }
     
  4. There are two more other ways to create aliases besaides using Aliases editor, they are :
     
    1. The first one is to write aliases in the Remote tab section in the Scripts Editor, by using alias declaration. The basic syntax for this method is alias alias_name contained_command(s) . See the below screenshot for the example.

      remotetabsectionmyfirstalias.gif

      on this example the function of alias declaration is to tell mIRC that myfirstalias was declared as an alias.
    2. The second other way is to declare the aliases in the EditBox (the line or lines you normally use to talk/type in), by using the /alias declaration with a / (forward slash) and the same syntax as in the Remote Editor.

      Once you type /alias myfirstalias /echo This is my first alias in the EditBox then press "Enter" on your Keyboard you should see something like this:

      addmyfirstalias.gif
       

Whatever the way you use to create your aliases they will do the same thing for you, choose one that is most user friendly for you. Now let's get on to something more interesting. Create an Alias named "what" for "/echo what do you think about $1- ? wasn't it cool?". Open your Aliases Editor and type the following codes to create the alias:

what /echo what do you think about $1- ? wasn't it cool?

Press Ok button to save the aliases and in the EditBox of your mIRC type /what mIRC Scripting Primer and see what you get. Congratulations!, (again?!).

You can replace "mIRC Scripting Primer" with some text you want, something like "Nevermind song by Nirvana" will work fine.

Did you notice the $1- in the codes? it's called Identifier. It's got predefined value set by mIRC. The $1- identifier acts differently to $1 identifier. Which the $1- represents All the text you type after a triggered alias while the $1 represents the first string only. Are you a little confused? Don't be. Create the following Aliases and see what they do, you will be clear about the $1- thing.

letters /echo My letters are : $1-
letter1 /echo the first letter is : $1
letter2 /echo the second letter is : $2
letter3 /echo and the third letter is : $3

Save your aliases then type the following in your Edit Box, and see what happens :

/letters mIRC Scripting Primer

then this :

/letter1 mIRC Scripting Primer

and this :

/letter2 mIRC Scripting Primer

This is the last one :

/letter3 mIRC Scripting Primer


Wasn't that cool?. There are many many more useful Identifiers, refer the Help File. The Identifiers from the categories of Time and Date, File and Directories, Nick and Address, Text and Numbers and Other Identifiers are a must-know. Other Identifiers, you can learn as you start writing more complex scripts and when necessary.
With this I close the chapter on Aliases. Next we will be learning about more other vast and important subject. so, watch my steps and happy scripting.

Tips: You want to test and debug your remote online scripts without being connected to the Internet?, just run your own IRC server and connect to it. A good one is WIRCSRV. Once you get it running type /server 127.0.0.1 in mIRC to connect.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...