Guide to mIRC Scripting By Eric Marcarelli REMOTE SCRIPTING: To start open mIRC and go to tools -> remote. This is where you will type most of your code. The remote is also probably the only part you'll need if you're making a bot. Once it's open type this: on *:text:hi:#: { msg $chan Hi } NOTE: If you are on more then one channel you will probably want to go in a testing channel and change the # to #that_channel. Now have someone (or a clone) type hi in the channel. You can't trigger an on text your self, which is a great thing for bots. You should say Hi. Take a minute to look at the code and see if you can guess how it works. Change things and see what happens. The on *:text:hi:#: part means that the commands inside the { } will be done if anyone but yourself says hi in the channel. A few things to note are that the commands are, for the most part plain mIRC commands. They don't need a / in front of them (you may put one if you wish) and that $chan will be replaced with the active channel (# works the same way). For a full list of commands type /help. We will also cover more basic ones as we move on. I'm sure your ready for more complex things so I'll move right ahead. Type this in the remote under the previous script (or in its place want to). on *:join:#: { notice $nick Welcome to $chan $+ ! Enjoy you stay! } Have a clone join. See how it's greeted? This script covers a few new items. You can probably guess that on *:join:#: means when someone joins the channel. For a full list of on something commands type /help on. $nick means the nick of the user that triggered the script. Notice $nick will send a /notice to the $nick. Since no commands can be directly next to other text, if you want a word to be next to something like $chan you must use $+. $+ simply connects the two words on each side of it. Now you understand the script, but there's a problem. Unlike text, you can trigger join. So, to stop this you need an if statement. If statements are VERY important, and luckily, easy to understand. Update that code with this: on *:join:#: { if ($nick != $me) { notice $nick Welcome to $chan $+ ! Enjoy you stay! } } The if tests to see if $nick is you, you are $me. If you aren't $nick the command is executed, if not the script stops. != means not equal, == means equal. Notice the if has it's own set of { }. These work the same as in C, when you open one you have to close it. To see if all are closed hit the { } button at the top right. What if you only wanted to send a different message to certain people? Say you wanted Guest1, and Guest2 to get special messages, and the rest, excluding yourself you get the normal one. Replace the script with this: on *:join:#: { if (($nick != $me) && ($nick != guest1) && ($nick != guest2)) { notice $nick Welcome to $chan $+ ! Enjoy you stay! } elseif ($nick == guest1) { notice $nick HEEEEEY $nick $+ !!!!! :D } elseif ($nick == guest2) { notice $nick I HATE YOU!! GET OUT!! >:O } } You can test it or just figure out what it does. Elseif works like if, it is simply the next one to check if the if or elseif above it didn't work. Once you study it's workings you'll see that this long script is simple and your ready to move on! Let's stay with this on join script, and see what it can do. How about making the regular message random? The notices timed to be sent 10 seconds after a join? Ok. First thing to do is create a new .txt file (use notepad) and save it to your mIRC folder with the name joinmess. Skip the first line of the file and fill it in like this: Welcome to $chan $+ ! Enjoy you stay! Hi $nick $+ ! Welcome $nick $+ ! Then save again. Now replace the script with this one: on *:join:#: { if (($nick != $me) && ($nick != guest1) && ($nick != guest2)) { timer 1 10 notice $nick $read(joinmess.txt) } elseif ($nick == guest1) { timer 1 10 notice $nick HEEEEEY $nick $+ !!!!! :D } elseif ($nick == guest2) { timer 1 10 notice $nick I HATE YOU!! GET OUT!! >:O } } The script looks more complicated, but it's really not. $read(filename) simply selects a random line from that file. The timer works like this. There is a . so you don't see it set and halt (annoying messages). The first number after timer is the interval to count in, in seconds. The second is the number of intervals. .timer 1 10 means in 10 seconds, .timer 60 60 would mean is an hour. Now what if this is a bot, or, even if is not. You may want to add some fun, to it make anyone able to add a line to joinmes.txt. Replace with this: on *:join:#: { if (($nick != $me) && ($nick != guest1) && ($nick != guest2)) { timer 1 10 notice $nick $read(joinmess.txt) } elseif ($nick == guest1) { timer 1 10 notice $nick HEEEEEY $nick $+ !!!!! :D } elseif ($nick == guest2) { timer 1 10 notice $nick I HATE YOU!! GET OUT!! >:O } } on *:text:!write message *:#: { write joinmess.txt $3- notice $nick Your message ( $+ $3- $+ ) has been added successfully. } The only thing that changed is the addition of the write script. When someone types !write message (text here), the (text here) will be added to joinmess.txt. /write adds a line to the file. Example: /write file.txt hi would add the word hi to the end of file.txt. But wait, why $3-? $3 means the third word with on text. $3- means the third word and beyond. That's fine for a while, but soon people start to abuse it. Messages like "GET THE FUCK OTTA HERE" are being added. You delete them but it still goes on. You like the script so deleting it isn't an option. The problem can be solved with an if statement. Replace with this: on *:join:#: { if (($nick != $me) && ($nick != guest1) && ($nick != guest2)) { timer 1 10 notice $nick $read(joinmess.txt) } elseif ($nick == guest1) { timer 1 10 notice $nick HEEEEEY $nick $+ !!!!! :D } elseif ($nick == guest2) { timer 1 10 notice $nick I HATE YOU!! GET OUT!! >:O } } on *:text:!write message *:#: { if ((*fuck* !iswm $3-) && (*shit* !iswn $3-) && (*damn* !iswn $3-) && (*bitch* !iswn $3-) && (*leave* !iswn $3-) && (*out* !iswn $3-)) { write joinmess.txt $3- notice $nick Your message ( $+ $3- $+ ) has been added successfully } else { notice $nick Your message ( $+ $3- $+ ) contains unsuitable text and will not be added. } } It looks like a lot is happening but only the second part has had any changes. These additions scan $3- for offensive text and, if none is found the message is written. If it is found it gives an error and is not written. Iswn checks to see if certain text is with in other text. !iswm means "something is not with in something". The word before iswm is the word looked for. An * in it means anything can be beyond that point, until other text. Example: *hi* would work with hi how are you, ummm hi there, and wouldn't work with hqi. How*you would work with how are you, how you, and wouldn't work with how are u. Else is different from elseif in one way, it doesn't test anything. It's just triggered if the other ifs aren't. Wow. Look what that simple script turned into! There is still a LOT more for you to learn about remotes. But this is where this guide leaves them. For more commands look to /help. POPUP SCRIPTING: Popup scripting is the best time savers I've seen when it comes to scripting. The sole purpose of them is to save time by just hitting a menu option. They are very simple and aren't THAT different then remotes. Click on the popups tab to the top of your screen (assuming you in the remote). You will see a script already there. That is the status screen popup. I don't find it useful to edit it so go up to view and choose menu bar. You should see soothing like this: Commands Join channel:/join #$$?="Enter channel name:" Part channel:/part #$$?="Enter channel name:" Query user:/query $$?="Enter nickname and message:" Send notice:/notice $$?="Enter nickname and message:" Whois user:/whois $$?="Enter nickname:" Send CTCP .Ping:/ctcp $$?="Enter nickname:" ping .Time:/ctcp $$?="Enter nickname:" time .Version:/ctcp $$?="Enter nickname:" version Set Away .On:/away $$?="Enter away message:" .Off:/away Invite user:/invite $$?="Enter nickname and channel:" Ban user:/ban $$?="Enter channel and nickname:" Kick user:/kick $$?="Enter channel and nickname:" Ignore user:/ignore $$?="Enter nickname:" Unignore user:/ignore -r $$?="Enter nickname:" Change nick:/nick $$?="Enter new nickname:" Quit IRC:/quit In popups the first word is what you will see in the menu. After the : is the script. If you want to enter text you use $$?="Explanation:". A box will popup when you use the popup with the text Explanation: and a text entry box. What we are going to do is update the away so that it tells everyone you are away and when you come back. Replace Set Away .On:away $$?="Enter away message:" .Off:away With: Set Away .On: { set %away $$?="Enter away message:" ame is away, reason: %away } .Off: { ame is back from %away away } Use the script once and you'll see basically what it does. Ame messages all the channels your in on that server. A . makes a sub menu option. Set %variable value sets the %variable to value. %away is set to be your current away info. Now we have that, but wouldn't it be great if it changed to a custom away nick too? To do this, replace the code with this: Set Away .On: { set %away $$?="Enter away message:" ame is away, reason: %away nick $$?="Enter away nick:" } .Off: { ame is back from %away away nick $$?="Enter your old nick:" } If you always want to change your nick back to the same thing you can use nick that_nick instead if nick $$?="Enter your old nick:". Popups are very easy to pick up on. Your current popups have examples for you. Now it's time to move on the final portion of this guide. ALIAS SCRIPTING: Click over to the aliases tab. You should see something like this: /op /mode # +ooo $$1 $2 $3 /dop /mode # -ooo $$1 $2 $3 /j /join #$$1 $2- /p /part # /n /names #$$1 /w /whois $$1 /k /kick # $$1 $2- /q /query $$1 /send /dcc send $1 $2 /chat /dcc chat $1 /ping /ctcp $$1 ping Alias, in my opinion are the weakest form of scripting. The first word is the trigger, (only you can trigger them) the rest is the script. This seems so self-explanatory I will only give one quick example: /hello msg $chan Hello! How are you? When you type /hello, you say Hello! How are you? Into the channel. Well with that my guide is ended. I put a lot of work into this, I hope it helped. If you need more assistance or have a comment look for me in #scripters, or email me at webmaster@programmingcentral.tk. Enjoy Scripting!