Writing your own scripts

Introduction

In this section of the tutorial I shall be introducing some very advanced concepts, which basically amount to computer programming. Don't be put off by this, as I will endeavour to explain what I'm doing every step of the way. Programming, however, is not for everyone, but it does require you to think clearly, logically and sometimes laterally. My mother used to have a copy of an adult-education advertisement she cut out of the local newspaper which stated "If you can follow a knitting pattern you can program a computer". As with reading and writing knitting patterns, computer programming is all about practice. First you have to learn the popular commands, then you have to learn how to put them in the right order to do what you want them to.

mIRC's scripting language can look complicated to the untrained eye, but then again, so can a knitting pattern. Take it slowly, step by step, run through everything several times until you're sure you understand it, and then move on to the next section.

Concepts in this section build on ideas built up in the Aliases and Popups sections, so make sure you understand the ideas presented there before moving on to this section.

After introducing some more scripting concepts with Remote Event Handling and User Access Levels, I shall present two script routines, one to check your spelling before you press enter, and the other to insert random colour codes before each word in the sentence. Lastly I shall show you how to turn these script routines on and off via a user-defined menu.

After all that, I hope you'll know enough about scripting to:

This scripting section of the tutorial is by no means intended to be exhaustive - it is designed to introduce some of the commands and show you what can be achieved with them. There's nothing overly 'clever' about what I'll present to you, in almost all cases there will be a better way of doing what I'm demonstrating. But then the examples would be convoluted and if there's one thing I've learned from seven years of writing computer programs for a living, is that you can be too clever for your own good sometimes!

Remote Events

WARNING!!! This is getting dangerously close to actual computer programming. Proceed only if you feel confident with everything described above. There is a lot of information in this section, and it is by no means a complete guide to mIRC Remote Events, it just gives you an idea of what can be done.

A remote event is, basically, anything that can happen while using mIRC. People join channels, people leave channels, chats and dcc connections are opened and closed, text is entered into the edit box and files are sent forwards and backwards. Each of these is an event, and mIRC can recognise that they have taken place and react according to your programing.

To enter remote events, you can open the mIRC Editor and select the Remote tab, or you can click the icon next to popups on the toolbar. You can see any remote events you have already set up, if any. A simple remote event is a person joining a channel. Suppose I want mIRC to perform a /whois on people as they join the channel. I would set this up as a remote event:

 on 1:JOIN:#:/whois $nick
Now, this is a short line of code, but there is a lot here.
on - this indicates that the event handler is active; it's switched 'on'. To disable the auto-whois change this to say 'off'
1: - You can allocate each user on IRC an access level, so that some code is only executed when certain people have caused the event to happen (more on this in the access levels section). The default access level is 1, which is all users.
JOIN: - There are several events mIRC can recognise, joining a channel is one of them. Other are ON SEND, ON RECEIVE, ON INPUT and so on. They are all listed in appendix II and described in full in the mIRC help file and FAQ.
#: - Different characters can be put here to indicate different types of events. For example, # indicates a channel event, which is the only one applicable for a JOIN event.
/whois $nick - This actually performs a whois on the person who has just joined the channel. The $nick identifier tells you the nickname of the person who last joined the channel.