eBook Irc & MIRC Commands

download eBook Irc & MIRC Commands

of 62

Transcript of eBook Irc & MIRC Commands

  • 8/10/2019 eBook Irc & MIRC Commands

    1/62

    I r c/ mI R C commands

    T his is the bas ic.. .you jus t HAVE to know this , or you won't be able to

    do much on I RC at all , beyond joining a channel and talk ing : ). Forscr ipting, knowing these commands well means being able to pull themost out of your client, you can't do ANYthing in a script without this.

    I R C comm ands

    T hese are general, specif ic for the I RC medium, and are mainlyfocus ed on the interaction between you and the server and otheruser s . T hese commands are detailed in the mI RC help file, and I 'l lleave most of them alone for your s tudying, however there are a few

    commands that are not mentioned in the helpfile (and that are notcommon on all networks ), and I 'l l mention them br iefly:

    -S ilence:

    T his is working bas ically j ust li ke /ignore, but has a fewimportant differences. First of all, while /ignoreis a client-side protection, meaning that you will still receive theincoming requests, your client will not process them,/silenceis a server-side protection, meaning if an usermatching your silence list tries to send you a request, itwil l never be sent to you. S econd, a /silenceworks only on

    CT CP's , nothing els e. T hir d, a /silencelist is cleared ondisconnect (similar to /watch) meaning you'll have to re-set it on each connect, if you have a lis t of 'permanent'silences. Usage: /silencenick/hostto add a nick/host toyour silence list, or /silence-nick/hostto remove, or just/silenceto view the current silence list.

    -Watch:

    T his is a more 'efficient' vers ion of the notify sys tem,cur rently only available on DALnet. T he watchli s t i s cleared

    on dis connect fr om a server, meaning that yourclient/script must remember the list, and reset it onreconnect to DALnet (mI RC does thi s by defalt fr om v5.5).T he watch lis t i s limi ted to 128 entr ies (nicknames towatch for). Usage: /watch< + nick1> [+ nick2... .+ nickN]toadd single nicks to the watchlist, /watch< # channelname>to watch an enti re channel, /watch< -nick> [- nick2... .-

  • 8/10/2019 eBook Irc & MIRC Commands

    2/62

    nickN]to remove nicks from the watch list, or just /watchto show your watch list. While notify only takes in accountthe nick of the notify-entr y, watch als o takes in accountthe host of the watch-entry, when notifying you of users inyour list signing on.

    mI R C commands

    T hese commands are specif ic to mI RC, and whi le many of them can beus ed dir ectly to affect your I RC ses s ion immediately, a good many ofthem are directed at scripters, and will have only limited / no meaningfor many r egular I RC' er s . T hese are explained well in the mIRC helpfi le, s o I wil l only comment on a very few commands here:

    -Alias : ( /alias [ filename(optional)] < name of alias(what you type to execute it)> < command( s )> )

    T his command allows you to add or modify aliases fr omthe command line. T his allow you to make small shortcutsto make your everyday I RC ses s ion eas ier, and while youcan' t us e this to create very advanced aliases for use inyour script, many people find it handy to save them typingand time. T o add more than one command to beper formed by the alias , us e a ' | ' to separate thecommands , ie;

    /alias hop par t # |join # $1Now you would just type /hop # mI RCto leave your

    cur rent channel and join # mI RC.-Help: ( /help [keyword] )T he helpfile does have it' s weakness es . B ut r eading it,often and thoroughly, can help you solve problems youhave, or j us t learning scr ipting. I f you' re making somethingthat s hould react to a ban being made, type /help on banand get help on the ban event, test it out, see how itworks , r ead some more, until you' ve got it r ight. I f you' restuck, ask, for instance in a helping channel like# HelpDesk, but be sur e you' ve read the help before you do

    : ) Of course, never be afr aid to ask, the helpfile is far fr omper fect, but it ' s actually quite good : )./helpjust opens thehelpfile in the contents listing, while /help < keyword>gives help on keyword.-R un : ( /run [ -n(optional)] < f i le to r un(including path, ifnecessary)> [parameters(optional)] )T his command runs a program, or a fi le (in which case itwill effectively execute the program associated with the

  • 8/10/2019 eBook Irc & MIRC Commands

    3/62

    file, using the filename as primary parameters), withoptional parameter s as well . T he -nswitch minimizes theprogram/file being run, in most cases . T he only reasonwhy I mention this command specifically i s a li ttle thingI ' ve noticed; many scr ipts seem to tend to use/run

    program.exe filename, in other words, running a programwith an additional filename as the file to open. While this isall fine and ok, it i s in most cases very unnecessary. I f youwant to open a .txt file in notepad, and .txt files areassociated with notepad (which they are on most winXXcomputers), then just using /runfilename.txtis a moreeffecient way of doing this . T his als o saves you from thetrouble of locating the program you want to run the filewith, but ins tead lett ing the O/S choose the appropr iateway to start it. Of course, nothing stops you from adding aprogram i f you want to force a fi le to be opened by aspecific program..- Echo: ( /echo [colour(optional)] [parameters(optional)]< T ext > )Echo is particularly handy for one thing, namely evaluatingidentifiers and expressions you use in your script. Forinstance, you want to know what the $server identifierdoes, simple, use //echo$server , and voil, you can seethat it r etur ns the name of the server you' re currentlyconnected to. Whi le this was a s imple example, you canput together complex constructions of identifiers for use in

    your script, and to evaluate them without having to runyour s cr ipt, you may us e the echo command. I f you' reonline, you can of course use //say, but //echoshows theresult to you only, and works while offline (note thoughthat some identifiers only will evaluate while online, suchas $server for instance: ) ) , //sayrequires you to be onlineand shows the result to everybody in the same channel asyou or to the nick of the user you' re having a querywindow open with. Us e echo : ). Please note that yes , youwill have to use // instead of just /, the double slashesforces mI RC to evaluate your input, if you us ed a s ingleslash, you would get returned just $server, instead of theserver you currently were connected to.

    Aliases

    As I mentioned in the commandssection, aliases can be cons idered asshortcuts , and/or as the equivalent of procedures, fr om the

  • 8/10/2019 eBook Irc & MIRC Commands

    4/62

    command line they are typically shortcuts, made to greatly simplifyyour everyday I RC ses s ion, us ed in a scr ipt, they are als o used tocreate more complex s tr uctures including mult iple commands andalternate actions taken, based on what additional par ameters youenter/in what kind of window the alias is entered, etc.

    A simple alias entered on the command line could be like this : /aliaspar par t # $1- which would then part the current channel, with anoptional message. Much easier than typing /par t # channelnamemessage, now you could just type /par [message]to do the same : )Als o, you' ve got a few channels you join often, s uch as # mI RC and# Chat, better than typing /join # mIRCand /join # Chat, you couldmake two aliases to join them, ie /alias jm join # mircand /alias jc join# chat, and you could even make an alias to join both; /alias ja { jc |

    jm } .

    More complex structures could be used within your script, to build aprocedure you could call from many places in your script, while onlyneed to wr ite it once, which would save space and make the editing ofit much easier..

    alias unlock { if (k is in $chan(# ).mode) { .s et % key $chan(# ).key mode # -k % key } els e { echo $chan No key set in # $+ ! }

    }alias lock { mode # + k % key |.unset % key }T his is but a s imple example on how you can us e an alias , and while itdoesn' t r eally s how the mor e advanced usage of aliases , it shows thebasic principles in using a multiline alias in your script. All this aliasdoes is enable you to ' unset' the channel key on a channel ( if it' s set),and then allows you to reset i t at a later point. T his is more towardsthe ' command line alias ' though, than a ' procedure' , but the way youdo it is equal. I f you include your aliases in the main s cr ipt fi le (and notin an alias - file of it' s own), you prefix the alias its elf withalias , thenyou add the desired commands, if you place the aliases in the alias file,

    you skip the 'alias ' prefix .Good scr ipting practice is also to clean up (r emove) var iables thathaven' t got any use once your s cr ipt finis hes process ing. T his can bedone with /unset% var iablename, or automatically by the use of atimer , with /set -u[time in seconds] % var iablename. I n the exampleabove, an as good (/better) solution would have been to use .set

  • 8/10/2019 eBook Irc & MIRC Commands

    5/62

    -u300 % key $chan(# ).key, which would unset the % key variable after5 minutes.

  • 8/10/2019 eBook Irc & MIRC Commands

    6/62

    I nt r oduct ion t o Popups

    Popups are the menu' s in your scr ipt. R ight click pulldown menu' s , andmenu' s access ible from the menubar . You create a popup in much the

    same format as an alias , with a few addit ional ' tweaks ' to make apopup look l ik e you want. T he bas ic look of a popup is li ke this :

    T it le/menu option: { commands to run }

    Popups 1I n this example, the title/menu is 'Connect til nettverk' , and ratherthan tr igger ing a program/command to run, it is branching to so-calledsub-menu ' s , and usually, popups will have sub-menu' s , to create amore logical and easy- to-us e inter face to the user . T o create the menuabove (which is located in the s tatus window);

    menu status {

    Connect ti l nettverk .Undernet ..s erver 1: { .s erver s omeserver .org } ..s erver 2: { server someserver2.org } .DALnet .. server 1: { .s erver yet.another .s erver .org } etc}

    As you s ee, you create the branching by adding one dot ' .' to eachsub-level you want to create, otherwis e the way you add the

    commands to be run is exactly the same as for aliases . T o create thedivider (line), for ins tance between ' Andre' and ' Om I RC nett' , you adda hyphen ' - ' to the menu level... that is , on the ' upmost (r oot)' level ofthe popups, you do like this;

    Choice # 1: { some commands }-Choice # 2: { More commands }

    I f you want to create the divider as above, it' s like this ;

  • 8/10/2019 eBook Irc & MIRC Commands

    7/62

    menu status { Connect ti l nettverk . ( .... ) .Andre .. ( ... )

    .- .Om I RC nett: { command to run }}

    Brackets:

    Pay attention that when you ' open' a menu (s tar t a menu section of ascr ipt) (or a command) with a { bracket, that you also close it, using a} bracket. I f you don' t, you wil l get all messed up popups , l ike..

    Popups 2so, if you see alot of garble in your popups when you test your new,to-be-world-famous script, then you should most likely scan yourpopups for a } that isn' t there..; ).

    U si ng ident if ier s and var iables w it hin your popups:

    You can also use identifiers and variables inside the popups, to makethem eas ier to us e or provide information about what wil l happenwhen you activate the menu, such as

  • 8/10/2019 eBook Irc & MIRC Commands

    8/62

    Dis connect fr om $server : { .s et % las tser v $s erver .s et % las tpor t $por t .quit Leaving}

    -Connect to las t - % las tserv: { .s erver % las tserv % las tpor t}

    I n which case the servername would show up in the popup, so if youwere connected to dallas.tx.us.undernet.org, the menu would show:

    Disconnect from dallas.tx.us.undernet.organd the Connect to last, would likewis e show the same. T he ' connectto las t' menu option is rather useless though, as this is what happens ifyou pres s the ' connect' button, but...; )

    Dyn ami c P opups:A final note (for now) on popups; making dynamic popups enables theend-user to only see features that is relevant for the use he will putthem to, and hide ir relevant featur es . Dynamic popups are GOOD. : )Ok, so what do I mean exactly? Well , something like this :

    Popups 3

  • 8/10/2019 eBook Irc & MIRC Commands

    9/62

    Popups 4

    On the fir s t pictur e, I ' m the lucky operator of a channel, and hasaccess to a few commands that are usable only i f you are a channel op(invite, set ban). On the second pictur e, I have been deop' ed, and thepopup access to the menu' s that r equire op have been r emoved, toavoid problems , and provide a cleaner look to the popups.More specifically, you create dynamic popups by us ingidentifiers/creating conditionals that will be either on or off, $true or$fals e etc etc. T his adds the ' show/hide' featur e of popups , and mays impli fy the everyday us e of the scr ipt you' re making : ). An easy wayto do the above popups would be li ke;

    .... . . .

    $i if($me isop # ,Opkontr oller).I nviter til $chan{ invite $$?= " Who should we invite to$chan $+ ?" $chan }.S ett ban { ... ... }.S ett ban alle kan { .. .. . }S end ti l $chan......

    T he above popup definition is us ing the identi fier $iifwhich will returnone out of two things , depending on the express ion you make. I n thi scase, the $iifchecks to see if you' re an op on the cur rent channel, in

    which case it returns 'Opkontroller ' . T he submenu' s belonging to'Opkontroller ' will then be enabled. I f you' re not an op, i t r eturnsnothing (which is als o a s tate), and hides the submenu' s from theuser. You can use most (all?) of the evaluators available in regular ifcomparisions, which enable you to do constructions such as

    $iif($me is op # &&$1 ! isop # ,Kick): { .kick $chan $1kickmsg }

  • 8/10/2019 eBook Irc & MIRC Commands

    10/62

    Which would result in a popup that wi ll ONLY s how if you are an op ina channel, AND (becaus e of the &&) the selected nickname in thatchannel is not another op : ) (by us ing the !prefix to the condit ionexpression).

    I nt r oduct ion to R emote Events

    Remotes is perhaps the mos t excit ing par t of regular mI RC scr ipting;while popups and aliases both require input from you, remotes arereacting on things entir ely without your interaction. I sn' t thatcooooool?? ; ) Remote events can be spli t into 3 main types ; 'regular 'events, rawevents , and ctcpevents . A li tt le knowledge of identf iersand bas ic I RC/mI RC commands, aliasesand identifiers will make thissection easier to understand. Also make sure remotes are turned on, ifyou type /remote, i t s hould show this:

    Remote 1

    if i t doesn' t, you can turn them on by typing/ctcps on, /events onand/raw on.

    R egular event s :

    T his is shor tly put events that i s neither r aw, nor ctcp : ) T his can be an

    user joining a channel you' re on, par ting it , s omebody typing sometext in a channel or query window with you, somebody sending you afi le, an op, deop, kick or ban event, or a soundfi le being played (byyou or other s ) etc etc etc. T he helpfilehas a list of all events, togetherwith examples on how to us e them and tips . E vents are generally inthe format:

    on level: event: command(s )

  • 8/10/2019 eBook Irc & MIRC Commands

    11/62

    Levelis here an userlevel, by default, all users have userlevel 1, andall ' on 1 ' events will t r igger for these people, unles s you haveconfigured it not to. Eventis the name of the event that should bedefined, and command(s ) is/are the command(s) to perform if an userof the requir ed user level tr igger s the event defined. S ome events als o

    have ways to r eact differently depending on wether the event takesplace in a specific channel, a specific window, etc, such as

    on level: event: matching: where/how: commandsin which case the 'matching' par t is requir ing the event to not only betriggered by an user of the correct level, but also that the matchingexpres s ion is fil led (the text event is a good example of this ). T hewhere/howpart of the definition sets requirements to in which casesinput is accepted, for ins tance ' # ' which will be fulfil led on anychannel, '# m I R C' which will only be fulfil led if the event is beingtriggered in # mI RC, ' ?' which will be fulfil led if t r iggered from anypr ivate message (iow, not in a channel) , and ' * ' which is fulfi l ledregardless of where/how the event was tr iggered.

    A couple of examples:

    on 1: DNS : { if ($ raddres s ) { clipboard $r addres s } }T his event wil l t r igger whenever you per form a /dns, be it on anickname or on a host / an ip address (or rather, when the dns haseither succeeded or failed), and if the address got resolved, it will copythis address to the clipboard, else it will not do anything. Here thelevel is '1' , theevent is 'DNS ' , and thecommand is 'clipboard

    $raddress ' ($raddress is anidentifier

    holding the resolved address).An example of the second kind of event, might be;on @1: TE XT : * suck* : # : { kick $chan $nick Please watch your language here in$chan guser 2 $nick 3}on @2:KICK: # : { mode $chan + b $addres s ($nick,3) }

    Okok, I know, this is two events , and I said one, but puleeeeaze, bearwith me? = ). T he @before the level here, means that it will onlytrigger if you are an op on the channel (for more info on prefixes and

    suffixes in events , check the section on user levels ). T he event is hereof cours e ' T EXT ' in the firs t part, and ' KI CK' in the second part, and thematching is '* suck* ' . T hewhere/howin this case is the '# ' whichmeans it will trigger on all channels (again, with the @ before thelevel, only on the channels you are an op), and the commandsarethe ' k ick etc' , and the ' guser 2 $nick' .What these two events do is that whenever an user type a word orsentence containing ' suck' in i t, in a channel where you are an op, i t

  • 8/10/2019 eBook Irc & MIRC Commands

    12/62

    will kick the per son with the message ' Please watch your languagehere in # channelname' , and then it wil l add the user touserlevel2.Next time you kick this person, you will also ban the user from thechannel, with the banmask* !* user@ * .domain. For more info on theus e of regular events , check the helpfile : )

    CT CP Events :

    CT CP s tands for ClientToClientProtocol, and CT CP events are eventsbeing triggered by the use of this protocol. Whenever you receive aCT CP reques t, your client wil l answer to this if there is a set answerdefined for the requested CT CP type, els e it wil l not r espond. T heformat of a typical CT CP event is s imilar to the 2nd type of r egularevent mentioned earlier, like;

    ctcp level: match: where/how: command(s )T he difference here is that the event par t of the definition, is actually

    the match. You can s pecify a specific word the event s hould tr igger on,or a wildcard match..for example:

    ctcp 1: PING: * : { ctcpreply$nick PI NG Z zz zz zzz zz zz zzz zhuh? = o I s$rand(1,3000000) seconds ok?}

    T his ctcp is reacting on a PINGr equest, and onlya PINGreques t. I nother words, send it a PI NGS r eques t and it hasn' t got a clue whatyou' re talking about, and will j ust ignore you ; ). T he '* ' indicates thatit will tr igger both on ctcp' s sent to the channel (# ), and to you

    privately ( ?). I t is a level 1 ctcp, which means that on most defaultconfigurations, this request will be answered from all sites (unless youhave them ignored, of course. T he ct cpr eply is a special commandthat sends your reply back in CT CPformat, you can also use ms g,notice, or nothing at all, j us t echoing to you that s omebody ping' edyou, etc. T his event s ends a ctcpreplyto the nick pinging you, with asilly message asking wether xxxseconds is ok. Here xxxwill be anumber between 1 and 3000000, randomly picked by using the $randidentifier .

    ctcp 3: *T IME* : ?: { notice$nick T I ME $ asctime($ctime) $+ . And you?

    ctcp $nick T I ME}

    T his one is reacting on CT CP' s that contain the word 'T IME' in them,so, it will answer both a request for CT I ME, T IMES , etc. Refering toabove, the '?' means that only ctcp' s sent dir ectly to you will beanswered, while requests sent to an entire channel will be ignored.T his is a level 3ctcp, which means that i t wi ll only be ans wered whencoming from an user in your userlist with a level that is 3 or above,

  • 8/10/2019 eBook Irc & MIRC Commands

    13/62

    and again, on mos t configurations, level 1 is ' all r egular users ' , s ounles s you have somebody added to your us er li s t, that ctcp won' t beanswered : ). T his ctcp sends a noticeto the nick requesting your time,with your date and time in a text format, and then the ques tion ' Andyou?' . I t wil l als o send a ctcp reques t back to the nick, reques ting

    his /her time.CT CPevents has got this nice thing about them, you can define yourown ctcp' s to respond to, not jus t the default ones (PI NG,T I ME,VERSION(and sometimes also CLI ENT I NFOand FI NGER), and of late;S OUND), and except fr om reacting on TEXT and NOT I CE(and similar)events , this is the only way you can s et your own events to react to : ).A special vers ion of the ctcp event is the CT CPREPLYevent, which willtrigger when an user responds to a ctcp request you sent him/her.CT CPREPLYevents are of the format

    on level: CT CPRE PLY: match: command(s )in other words, this is really just a regular event of the 2nd typementioned above, the only reason why I mention i t here is that i t isreacting on ctcp' s .

    RAW:

    T his is the one kind of events that the helpfile is not cover ing verywell, perhaps because it is a rather big ' field' to cover . Raw events isevents that trigger on messages the server sends you, for instancewhen you connect to a server, when you is sue a /whois , whensomebody invites you, etc. What makes Raw different from regular

    events ? Well , while regular events are mI RC specif ic, and the format ofthem are specif ied by mI RC, Raw events are defined in the RFC( z ip' edhere) regarding I RC networks , and the format i s very var iable. Rawevents are also called ' numerics ' , or ' numeric events' , as they' redefined by numbers , and you indicate them by numbers whenscr ipting. T he format of r aw/numer ic events is

    raw numeric(number): filter : command(s )Where r aw is the same as 'on' , j ust an word identifying this as anevent, raw event in this case. Numeric is the numeric to trigger on,f i l ter is a rule for when the numeric should trigger the commands,same as the matchin on textevents. Most commonly you will want to

    use some kind of wildcard filter , or j us t a ' * ' to catch all events . Youcan look up the numerics in the RFC, or you can us e an alternatesource, there are a good number of web based lis ts of the numer ics , aswell as hints on how to use them etc. One of the better/moreconvenient sources , is Jeeps ter' s numer ic reference, found in both theregular web based format, as well as in a regular windows helpfile, youcan find the helpfile here.An example of a raw event may be

    raw 433: * : {

  • 8/10/2019 eBook Irc & MIRC Commands

    14/62

    echo -a S omebody is already us ing $2$+ ! Automaticretry? (F3) halt }

    Raw 433is the numer ic for ' nickname alr eady in us e' , in other words ,when you issue a /nick < newnick>command, and the nick is taken,

    the server sends you a 433, and in this case, the event will betriggered. What this example does is to echo to your active screen thatsomebody' s us ing the des ir ed nick, and then it ask s you wether youwant to automatically retry the nick change, until you succeed (notethat this must then be scripted so that there actually is an alias thats tar ts when you pres s F3 = P), then it halts the regular output to thescreen (which is ; < nickname> Nickname is alr eady in use.).But why $2? T he format of r aw events is typically (not always ) that $1is the requester, and $2is the reques ted item. I n this case, thatmeans the reques ted nickname. You s ee the problem? T he formats ofnumeric replies is very changeable, so you will have to learn theformat of the specific numeric event you intend to react on/modify,always . You can use Jeeps ter' s numer ic par ser (script), or a similar(but slightly more advanced) script I wroteto catch the numeric whenit appears, or you can use a more simple method (also courtesy ofJeepster):

    raw * : * : { echo 12 - s Raw $numeric$+ : echo 12 - s 1: $1 2: $2 3: $3 4: $4 5: $5 6: $6 7: $7 8:$8 and 9+ : $9- halt

    }Place that line in your r emotes , and every s ingle raw wil l be echo' ed inblue in your s tatus screen. T he $numeric identifier holds the number ofthe numeric event being triggered, in the example above it will be like;

    Raw 433 :1: Yournick 2 : Newnick 3 : Nickname 4: is 5: alr eady 6: in7: use 8: and 9+

    like this :

  • 8/10/2019 eBook Irc & MIRC Commands

    15/62

    Remote 2and the parameters from 1-8 will be numbered, while parameter 9 andout (i f ex is tant) wi ll be jus t echo' ed in one bulk . Whi le regular eventsand ctcp events tr igger by other people' s actions, r aw events areresponses the server sends back to you, triggered by your own or yourI RC clients actions (in the above example I was tr ying to take the nick' I O' . ; ))

    I den t i f ier s # 1

    Knowing identfiers is go/no go when working with remotes, and youwill only be able to do very s imple s tuff in aliases/popups , i f you don' tknow how to use identifiers. However, most idenfiers are fairly straight

    forward learning from the helpfile, and fr om mI RC 5.50, they are als oclassified in subsections, making it easier to locate the identifier youneed. T o get help on any identi fier , us e /help $identifiername,forinstance /help $me. T o show the valueof an identifier, type (in anywindow) //echo -a $identi fiername. Let' s move on..

    T his section is split in four;

    Working with identifiers

    Basic identifiers

    More identifiers

    I ntr oduction to Token identifiers

    W or king w i th ident i f ier s

    T his is ways of combining identifiers , small tweaks and things you cando

  • 8/10/2019 eBook Irc & MIRC Commands

    16/62

    Fi r s t: Parameter s are ' words ' , s eparated by spaces ,usually. T his means that ina line like: I am s leepy, ' I ' would be parameter one, ' am'parameter 2, and' sleepy' parameter 3. : )

    $ 1 : Parameter one, ie /alias sleepy say $1looks sleepy,would enable you totype /s leepy B 0Pand you would then say 'B0P lookss leepy' in the channel.$2is parameter two and so on. T his is valid for manycases, not just like here,in aliases , but als o in popups and r emotes . I f you specify$1- it meansparameter one and out, if you specify $1-5it meansparameter one through five.

    $$ vs $ . I f you specify an identifier with $$ instead of $,this means; requirethe parameter to be there, els e halt. I f you s pecify j us t $,it means; use itif ex is tent, els e ignore. For ins tance

    /alias mop mode # + oooo $$1 $2 $3 $4

    would generally allow you to type /mop < nick1> < nick2>etc to op the givennicks, in this case it would require nick1 to be there, if notit would halt.I f you had specified jus t $1 instead of $$1, you could stillhave typed/mopall by itself, and the alias would have attempted toperform the command,and you would have received an error message. When youspecify $$1, it meansthat if there is no parameter one, i t won' t even tr y to doanything, andthus reduces the likelihood of problems.

  • 8/10/2019 eBook Irc & MIRC Commands

    17/62

    $? and $$ ?. T he ques tionmark pops up a dialogue, withan optional explainingtext, for instance

    /alias q quit $?= " Enter your quit mess age here

    (optionally)" now you could type /qand it ' d pop up the dialog askingyou for your quitmessage, and if given it would disconnect you using thequit message, elseit would j ust quit us ing mI RC' s s tandard quit message.

    # $ 1 an d # $ ?. T he # prefix means that the parameterentered should be prefixedwith a # character if one is n' t given, meaning that an aliaslike

    /alias j join # $$1

    would enable you to type /j mircor /j # mircalike, to join# mIRC.

    $ ! . T his identifier is fil led with whatever was typed in adialog-box, right

    before the usage of $!. For instance in an away alias

    /alias a away $$?= " Why are you going away?" |ameis away $!

    Now you' d type/a, and a dialog would pop up asking whyyou were going away,after which it would set you away and tell all channels youwere away, withthe away message you just entered. Also note that sincewe us ed $$?this aliaswould not do anything if you pres sed cancel or didn' t giveany away message.T he ' |'is explained more in the alias section, but generallyit allows you tomake aliases that performs more than one command, youuse a ' |'between eachcommand to per for m.

  • 8/10/2019 eBook Irc & MIRC Commands

    18/62

    $ + . A very useful identifier for the many cases where youcan' t dir ectlytype a word fully, or where you need to put together two

    ' separate' partsof a word. T his can be for ins tance when you need to addone or more extracharacters to an identif ier , such as

    Kick: { .kick # $s nick(# ,1) $?= " Why are you kicking$s nick(# ,1) $+ ?" }

    as you can' t use mos t identifier s like $identifier?or$identifier ' s etc, youwill generally use $+ to achieve this effect. T his will als o bethe case ifyou want to colour the evaluated identifier, likectr l+ k12$ identifier, thiswill lead to the identifier not being evaluated, you will needto put spacesbetween the colourcode and the identifier, l ik e ctrl+ k12 $+$identifier.

    $ & . T his identifier is more of an ' accessor ies ' identifier , it

    allows you tobreak long lines up into shor ter pieces that wil l be ' puttogether ' when run,for instance:

    show { echo -a T his line is long, and what more is , it' s

    VERY VERY $& long, however, us ing this identi fier we can break it

    up, $& while mI RC s ti ll wil l evaluate it as a s ingle, long

    line.}

    a very s imple, very s il ly example : ).

    B as ic ident if i er s

  • 8/10/2019 eBook Irc & MIRC Commands

    19/62

    T hese identifier s are es sential to know.. : )$me: Your nickname

    $ip: Your ip address (numeric)

    $chan: T he channel you' re cur rently on (als o, the channelan event was tr iggeredon, if used in remotes). You can also use $chan(0)toreturn the number ofchannel you' re cur rently on, or $chan(number/# ).proper ty(where property can betopic, key, l imit , ial or mode). $chan(3)will return thename of the 3rd channelyou joined, out of your currently joined channels (ofcourse, provided you reallyhave joined more than 3 channels = P). $chan(# ).keyreturns the key that is set inthe current channel (if any, of course), and $chan(2).modereturns the mode thatis set on the second channel you joined.

    Next

    I dent if iers # 2

    Mor e us eful ident if i er s..

    T hese are identi fiers you wil l need to know in most any s cr ipting,and/or gain you when writing aliases/popups as well.

    $mircdir : Returns the path fr om which your mI RC iscurrently running, iec: \program fi les\mirc\or the li ke. I f you need to indicatesubfolder s or fileswithin this path (for instance mirc.ini or download) use itlike $mircdirsubpathor $mircdirfilename, like $mircdirmirc.ini , or$mircdirdownload. You willtypically use this one to refer to the mircdir itself, orsubfolder s of i t.

    $scr iptdir : Returns the path to the current script, ie

  • 8/10/2019 eBook Irc & MIRC Commands

    20/62

    c: \program fi les\mi rc\addons etc. I t' s par ticular ly handy ifyour script isus ing more than one file for i t' s code, and you want torefer to the other files,or if you just want to make sure any stored data will be

    s tored with your scr ipt,and not in any other folder randomly chosen by mI RC /your o/s. Usage similar to$mircdir , ie $scriptdiraliases.mrc, to refer to the file' al iases.mrc' in thescript' s folder.

    $dir : T his identifier opens a regular ' brows ing' dialogue,and allows the userto click his way to the folder he wants, and then select thefile he wants.No typing of ful l path or the like, j us t click : ).Usage: $dir[= " sometext"] [initpath][ f i lename/ mas k].For instance, used in popups:

    Load an addon: { load - r s $$dir = " S elect f ilet o load" $mircdirAddons\* .mr c}

    which then will open a ' select file' dialogue in the ' Addons 'subfolder ofmI RC' s main folder , us ing the filemask* .mrc, which justmeans it' ll show only.mrc files by default. You can omit everything except the

    identifier itself,if you wish, though s ome explaining text of what' sexpected by the user isus uall y a good thing : ).

    $f indf i le: T his is actually j us t a quite nice file locator,equal to the ' find'option fr om your regular windows explorer : ) You s pecifythe parameters, andthe identifier retur ns the findings : ).Usage:$findfile( ,< match> ,< occurrence> ,[depth],[@window],[command])Directoryis the ' root' of the search (the topmost folderthat is beingsearched), matchis the pattern you' re searching for , andoccur renceis

  • 8/10/2019 eBook Irc & MIRC Commands

    21/62

    which occurrence that show up (yes, only one will show up,meaning, if youwant more than one occur rence to show up, you will haveto loopthe search).Depthis the number of ' levels ' of subdir ector ies that will be

    scanned,@windowis where the output may be presented, andcommandis a command thatwill be performed on all found files. Depth, @window andcommand are optionalparameters , whi le the 3 fir s t are mandatory . T he identifier$finddir is exactsimilar, but finds a folder/directory.

    $readini:I f your scr ipt needs to store data, var iables areall well and good fortemporary storage, but for more long-term based storage,an .ini file is usuallypreferrable. You store the data using the /wr i te in i command, and retrieve thedata using the $readini identifier.Usage: $r eadini [ -n] [path\]< filename> < section>< item> , for instance

    I dentify to nicks erv: { nicks erv identify$readini pw.ini nicks $me }

    which will then identify to nickserv with the given

    password, provided of coursethat you first had created a file containing these passwords: ). T he -nswitchis optional, when s pecified the retur ned info won' t beevaluated, but t reated asplain text (For instance if the above returned % test, itwouldn' t try to showthe value of % tes t, but jus t return % tes t). Pathis optionalas well.$ial: T he ial i s mIRC' sI n ternal Address L is t , allowingmI RC to work much fas terand convenient with user ' s addres ses , than it would dowith having to look up eachaddress each time you would need it (for instance withbans , s cans etc). I t als oallows you to retrieve information that you else would haveto use r aw events for.

  • 8/10/2019 eBook Irc & MIRC Commands

    22/62

    Usage: $ial(mask,# )[ .proper ty]where maskis theaddress mask you want to match,and # is the address number to return. Property can benick, user , host and addr.I f you set # t o 0 , it will return the number of total

    matches , which you then canuse in a loop to show matching addresses, for instance(this is using theproper ty .nick and .addr , r etur ning the matching user ' snick and address):

    alias scanadd {; sets the max number of nicks to scan. set -u0 % max $ial($$1 ,0) : loop inc -u0 % c; checks that we aren't counting more thanthere are nicks i f (% c < = % max) { echo -a Match nr % c found is$ial($$1 ,% c).nick on $ial($ $1 ,% c).addr goto loop }; % c is larger than % max; no more nicks toscan, we're done! els e { echo -a End of scan! }}

    Which will then return the nicks (and their addresses)matching the hostmaskyou enter (like /scanadd * !* @* .com) (note that thisexample doesn' t check forerrors, so it would be up to the user to enter a valid maskto scan for). Forhelp on the various kinds of address masks, look up on$mask (/help $mask).

    $nick: T his identifier can, s imilar to $chan, be us ed alone,in which case itrefers to the nickname of a person triggering an event, orit can be us ed withaddit ional propert ies ;Usage: $nick( # channelname,# /nick) . $nick(# ,0 ) willreturn the total number ofnicks on the cur rent channel, while $nick(# ,2 ) i s thesecond nickname in the

  • 8/10/2019 eBook Irc & MIRC Commands

    23/62

  • 8/10/2019 eBook Irc & MIRC Commands

    24/62

    which then will notice the person you get the pingreplyfrom, telling him/herhis pingtime in s econds . T he above example is j us t asimple substraction, youcan us e much more advanced calculations if des ired, of

    course.

    $active: $active returns the name of the currently activewindow in mIRC.. .thus ,it also returns the name of chat/query windows, and thes tatus window. T his isuseful if you want to make anything that should respondon the currently openwindow, r ather than a channel or the l ik e.

    $window: T his is an identifier specific to cus tom windows,and while it' s got anumber of .proper ties, I will only mention it briefly. .in anif-then-else matchyou can s pecify if ($window(@ windowname)) { commands} to verify that the windowactually is opened etc. T his should help you avoid tons of/aline: no such window er ror ' s ..: )

    $event: T his one retur ns the name of the event that wastriggered (thus, onlyvery us able when placed in a remote event = P).

    $numeric: Similar to $event, returns the number of thetriggered in the numericevent, thus only us able when placed in a raw event.

    $ul i s t : Yet another remote identifier, this one returns theaddress in theuserlist matching the specified address and level.Usage:$ulist($mask,Level,# ).For instance, if you want to list users in your userlist froma par ticularaddress , on a level of your choice;

  • 8/10/2019 eBook Irc & MIRC Commands

    25/62

    S how user s { set -u0 % pattern $$ ?= " Enter pattern to search for ,ie * !* @* .com"

    set -u0 % level $$?= " Enter level to show"

    set -u0 % max $ulist(% pattern,% level,0) : loop inc % cnt 1 i f (% cnt < = % max) { echo -a $chr( 35) $+ % cnt is

    $ulis t(% pattern,% level,% cnt) goto loop }}

    T his could be a s imple popup, which would li s t the user s ofa specificuserlevel, after the requesters criteria. Note that in thisone there is noerrorchecking, it just shows how you could use $ulist, abetter example mightbe

    on 1:KI CK:# : { if ($addres s ($knick,3) iswm

    $ulist($fulladdress,protect,1)) {

    ; if the user that got kicked is a user in your ' protect'l i st

    ; deop kicker and invi te the k icked user back in mode # -o $nick | invi te $knick $chan }}

    Might be a possible way to use it.

    $away: T oggles on the bas is of your away s tatus , i f you' reaway, this onereturns $ true, if you' re not, it r eturns $ fals e. S o you coulddo

    on 1: DCCS ERVER : CHAT : {

  • 8/10/2019 eBook Irc & MIRC Commands

    26/62

    if ($away) { .notice $nick Hey sor ry, I ' m away |halt }

    }

    halt ing incoming chat' s if you were away.

    $cb: Returns the clipboard content (or the first 256characters of it, anyway).Works together with the /clipboardcommand. Usage$cb(# ), with properties.len . $cb(0)returns the total number of lines in clipboard,while $cb(0).lenreturns the total length of all lines in clipboard.

    $ i i f : T his is a cutie. I f you want to make dynamic popups ,$iif is a good wayto achieve just that. Usage: $iif(condition,true-result,false-result(optional)) .S ay you want to make a popup that s hows up only whenyou' re op' ed, and when thechannel you' re on is not r egis tered, you can do somethinglike;

    $iif($me is op # &&r ! is in $chan(# ).mode,Regis ter

    channel) { etc }

    would make a popup that enabled channel r egis tration onlywhen you could doit , els e it would hide the popup totally. You don' t have todo the doublecompar is ion as above, us ually you' ll only have onecondition to be met. Alsonote that while I here didn' t specify the ' fals e' s tatement(to get the on/offfunction, you can of course specify one, such as:

    $i if( $away,Retur n,Go away) { if ($away) { away }els e { away $$?= " Why?" } }

    which would then show ' go away' if you were not away, or' return' i f you wereaway : ).

  • 8/10/2019 eBook Irc & MIRC Commands

    27/62

    $version: T his r eturns the ver s ion of mI RC you' re using,you can use it in theon load command of your script, to verify that your target

    user will be able torun the script, ie:

    on 1: LOAD: { if ($vers ion < 5.5) {

    echo -a T his scr ipt will only r un on mI RC 5.5 orbetter, you are

    echo -a adviced to upgrade your client, which canbe done at

    echo -a $chr (1 60 ) echo -a http: //www.mirc.co.uk echo -a $chr (1 60 ) echo -a Halting ins tallation due to incorr ect mI RC

    version! halt } els e { blah }}

    T his line will then check the mI RC ver s ion for being lowerthan 5.50, if

    this is the case, it will halt the loading and advice the userto upgradehis client : ), els e it wil l proceed the loading.

    I ntr oduction to T oken I dent i f ier s

    by B 0 P @ # HelpDesk

    Welcome to this introduction to tokens , as used in mI RC scr ipting : )

    Many people hes itate to learn tokens due to the helpfile' s somewhatlacking explanation on what tokens actually are, however, once youtr y, you' ll find that tokens are easy to lear n and very us eful in youreveryday scripting.

    Let' s fir s t s tar t with what tokens really are: T okens are " par ts " of alarger whole, be it words in a sentence, parts of a word, parts of anaddres s and so on. Pictur e a piece of land. T his is the " whole" we' re

  • 8/10/2019 eBook Irc & MIRC Commands

    28/62

    talking about. T here are several people owning smaller pieces of landon thi s larger piece, these s maller pieces are tokens. T he smallerpieces of land are separated by fences, this is the mysterious " C"character, the " thing" that consti tutes the border s of the tokens(r eally; separates the tokens) .

    T he mI RC helpfile refer to tokens and the use of token identifiers inthe way T EXT , T OKEN, C, N. TEXT is the "whole" that we want towork with, TOKENis the exact text that is the token, Cis the AS CI Ivalue of the character that separates the tokens (since a token is apart of a larger whole, there must be something that indicates whatmakes up the parts), and Nis a number . Confused? Don' t wor ry, i tgets wor se ; )

    Example # 1

    Let' s work with an example: You want to make a wordkicker that k ickson bad words , s ay pu* * y, the only problem with this is that i f you dothis line (the regular way);

    ON @* : T E XT : * : # : { if (badwordis in $1- ) { kick $chan $nickWordkick } }it ' ll kick i f there is an user us ing a word that contains the badword, inthe above example, pus sycat for ins tance. S o how do we prevent this ?We can use the token identifier called $istok ( --$ is tok(T EXT , T OKE N,C) --) : $is tok r eturns $tr ue if a token exis ts intext, and $fals e if it doesn' t. I n this case, theTOKENis badword, andTEXT is the complete sentence, but what is C? T he "character"separating the words in a sentence, is a space. Yes, there is an asciivalue for a space, 32. S o what we tr y is this line.. :

    ON @* :T EXT : * :# : { i f ($i s tok($1- ,badword,32) = = $true) { k icketc.. } }T his li ne wil l ONLY k ick if badword is an exact word in the sentence, i twill not kick if badword is a part of another word in the sentence.

    Example # 2

    Let' s take another example while we' re at this . We wants to count thenumber of words in a sentence, so we finds the identifier $numtok ( --$numt ok(T EXT ,C) --) and finds out that this is what we want (note:you can also use $get t ok(T EXT ,0 ,C) for this):

    ON * : T EXT : * : # : { echo $chan $nick used $numtok($1- ,32 )words in his sentence }T otally pointles s , but it il lus tr ates the use of $numtok.

  • 8/10/2019 eBook Irc & MIRC Commands

    29/62

    Example # 3

    One last example.. We want to make a script that automatically runs atr aceroute with an external program on an user ' s hos t. Ok, we could

    jus t do a dns and capture the r esolved address , but for this tutor ialspurpose we' ll do it with tokens. T he identifier we' re looking for is

    $gettok (-- $gett ok(T EXT ,N,C) --) , which returns the N' th token inthe text entered. L et' s look at a typical addres smask, as we see themon I RC.

    [email protected] n this addres s , Bonziis the nick, blehis the user' s identd, and the res tis the user ' s hos t, in other words what we want to pass on to theexternal program. How do we retrieve it? TEXT will here be the entireaddress, for Nand Clet' s look at the addres s again. We see that thehost has the @ before it, so the @is the separating character (C).Now, if N was 1, we' d get the par t of the addres s _ before_ the @, but

    we want the host, so Nmust be 2. T he ascii value of @ is 64 ( --/ / echo -a $asc(@ ) --) , so the line we end up with is something likethis. . :

    //run externalprogram $gettok([email protected],2,64)T his will execute this command: /run externalprogram mp-217-245-170.daxnet.no.By now you hopefull y have a better idea on what tokens ar e, and abas ic idea on how to us e them, check / help t oken ident if i er s for alist of all token identifiers, as well as some tips on how to use.

    I nt r oduct ion t o Var iables

    A variable is a t emporary s t orage s pace, an "item" that can store anumber, a string, a character, or most anything you set it to. Variableshas to be assigneda value to actually return any value, anunassigned variable will not have any value, thus it will not exist(there' s a few exceptions to this , which we' ll come back to later on).

    Being temporary storage holders, variables are useful for storing dataused in commands and functions such as loops, dialogs (temporarystoring input until the "Ok" button actually is pressed), awayreasons,temporary data in a calculation, etc. Many people us e var iables tostore settings for files, which is a less good idea, both due to the non-permanent nature of variables, and since many scripts unset variables,and may unintendedly unset variables used for storing settings.

  • 8/10/2019 eBook Irc & MIRC Commands

    30/62

    S et t ing and uns et t ing var iables

    T o as s ign a value to a var iable, we use the /setcommand. /set % temptestingwill s tore the s tr ing testingin the variable % temp, which then

    may be used for anything you please...type //echo -a % tempto seewhat' s s tored in % temp. T o remove the as s igned value and removethe variable, use the /unsetcommand. /unset % tempwill clear thevalue of % temp, and remove the var iable from the var iableli s t. Both/set and /unset has switches which modify the way they perform theaction, /set - s wil l echo the value you' re as s igning the var iable to, asyou are setting it, whereas /set -uNwill set the variable, and thenunset i t after N seconds . I f N is 0, the var iable wil l be unset as soon asthe current command/function has finished performing (this is veryuseful for loops and functions where the variable only really is neededwhile the function is performing. When unsetting a variable, you mayuse wildcards to unset more than one variable at once, as well asspecifying two or more variablenames in a single line..f.ex /unset% temp* or /unset % temp % tes t. A special variation of the /unsetcommand is the /unsetall, which unset' sall variables from the variablelist.

    Modifying variables

    You may incr easethe value of a var iable by us ing the /inccommand,if you specify a value that value wil l be added to the var iable,

    otherwis e the var iable' s value will be increased by 1 . I f the var iable didnot exist before you used the /inc command, it will be cr eatedwith avalue equaling the /inc' s value, i f no value specif ied, i t wil l have thevalue 1. You may use the -uNswitch with /inc as well, in a similar wayas with /set. Likewise, you may use /decto decr easethe value of thevar iable. S imi lar ly; if the var iable did not exi s t before the /dec, it willbe created with a value equaling the /dec' s value.

    Using variables

    S o, what do we us e variables for? Well , as mentioned before we may

    use them for storing data for use in functions such as loops,awayr easons, tempor ary data in calculations etc..let' s look at anexample: T his may be used in an aways cr ipt, where the we wis h to sayhow long we' ve been away when we r etur n. We can us e theidentifier$ctimefor this. $ctime by itself returns the number of seconds sinceJanuary 1s t, 1 970 (don' t ask me why 1970 = P), based on your curr entsys tem time. T his we can use in a s imple calculation like this .. :

  • 8/10/2019 eBook Irc & MIRC Commands

    31/62

    Go away: { set % atime $ctime|ame is away $$?= " Whyare you going away?" | .away $! }Retur n: { ame is back, was away for$duration($calc($ctime - % atime)) |.away }

    T hat' s a bas icpopupfor going away/r etur ning. T he Go away popup

    assigns the variable % atimeto the value of $ctime, then sends amessage to the channel in the form of an action (/me) stating thatyou' re away, and why, then sets you away with that r eason. T hereturn popup sets you back, and announces this to the channel. $ctime- % atimefinds the number of s econds you' ve been away, while$durationconver ts this number to weeks /days /hours /minutes/sec' s .Another example, we want to l is t the fi les in c: \temp, and echo thisinto the status window.

    alias listfiles {set -u0 % max $findfile(c: \temp,* .* ,0 )echo - s L is ting files in c: \temp..: loopinc -u0 % cif (% c < = % max){ echo - s $findfile(c: \temp,* .* ,% c) |goto loop}echo - s Finis hed li s ting files in c: \temp!}

    Here the variables % maxand % ccontrol the loop, what this alias doesis that it fir s t as s igns % max to the number of files in c: \temp, then itsets up a loop that lasts as long as % c is smaller or equal to % max,

    thus li s ting file 1 thr ough % max in the loop. B y us ing the -u0 s witchwith the inc and set command, we ensure that the variables are goneas soon as the loop is done with, by far the cleanest way of making ascript.

    L ocal var iables

    With mI RC 5.6 came a new kind of var iables , localvar iables. T hesevar iables are " local" to a scr iptl ine and are unset once the scr iptfinishes performing, and can only be used by the script itself (thus not

    called from the commandline), much similar to local aliases. A localvariable is assigned a value with the /var command, and can bemodified using /inc and /dec as usual. T o as s ign a local var iable, us e/var % var iablename = value.

    Var ious s cr ipt in g iss ues

  • 8/10/2019 eBook Irc & MIRC Commands

    32/62

    T his section wil l concentr ate on a few less categori ze' able sectionswithin scriptings that are often requested, and require a bit more in-depth focus than the FAQ can provide.As with any s ubject, if you' vegot suggestions on what we should have here, or comments, pleaseemail us : )

    * I f-then-els e- T his is one of the most impor tant things to know forany s cr ipter , as mos t everything you' ll do will need to use if- then-els etechniques .

    * Loops- T his ar ticle shows you what loops are, how to use them andthe differences between GOT O and WHI LE loops .

    * Raw events - Ever wanted to do a kick based on the channels otheruser s are on, or wr ite your own whois ? You' ll use raw events for this ,

    learning raw events is a very r ewarding effort : )

    * Cus tom windows- While less useful now than before, thanks todialogs, still a powerful feature.

    * Hash tables- mI RC' s newest, and for many purposes , bes t, way ofs tor ing data.

    And this is but a few topics, give us inputon what you want an articleon, and we' ll add it : )

    I f-t hen-els e

    Welcome to this li ttle ar ticle where we' ll look at one of the key-elements in mI RC scr ipting, and for that matter , in any programminglanguage; the if- then-els e s tatement.

    Required knowledge for this article is identifiers and aliases .

    W hat is i f-t hen-els e?

    I f-then-els e, or j ust i f -statements is short terms for I F this is true,T HE N do this, EL S E do something else. I t' s a tool that allows us tocreate code that is dynamically changing depending on s everal factorssuch as us er input, mI RC vers ion etc, ins tead of doing one thing and

  • 8/10/2019 eBook Irc & MIRC Commands

    33/62

    only this one thing. Knowing if-then-else is crucial if you want tobecome a good coder.

    T he synt ax

    I F ( v1 OPE R AT ORv2) T HEN { execute th is code } EL S E { execute this code }We' ve als o got a var iation of this ;I F ( v1 OPE R AT OR v2) T HEN { execute th is code } E L S E I F ( v1OPE R AT OR v2) T HE N { execute th is code } EL S E { execute th is code }

    Operators

    An operator is a function or symbol that determines how v1 iscompared to v2 . Most common is = = , which means is equal to, meaning is larger than. Other commonlyused operators are = = = (Case S enS iT ive is equal to), != (is not), > =(larger or equal to), < = (smaller or equal to), is in(v1 is in v2), iswm(v1 is a wildcard string in v2), ison(v1 is on channel v2), isop(v1 is anop on channel v2), ischan(v1 is a channel which you are on). T hereare others , consult the mI RC helpfile (/help if- then-els e) for more infoon the subject. You can als o do multiple I F s tatements in one line byusing &&or ||to combine them, && meaning AND ( i f (statement1)AND(s tatement2 ) ), ||meaning OR ( i f (s tatement) OR(statement) ). Finally, you can negate an operator with placing a !infr ont of the operator , thus ! is op would mean (v1 i s NOT an op on

    channel v2).

    An example

    alias hug { if ($1 = = $me) { describe $active gives himself a nice hug} else { describe $active gives $$1 a nice hug}}T his code bas ically s ays ; I F word1 i s your own nick, then do a /megives himself a nice hug), ELS E do a /me gives word1 a nice hug./describe is a command that does a /me to the target, in this case thetarget is $active, the active window.

    $i i f

    T his identifier is good for tes ting what an if s tatement would return,the syntax is:$i i f (s tatement is t r ue,do this ,else do this )

  • 8/10/2019 eBook Irc & MIRC Commands

    34/62

    T ry for ins tance //echo -a $i if($chan(0) > 0,You' re on one or morechannels ,You' re not on any channels )$chan(0)will return the numberof channels you' re on, the if s tatement thus says ; if you' re on one ormore channels , then echo "You' re on one or more channels " , els e echo" You' re not on any channels " .

    Aside from testing purposes, $iif is good for creating dynamic popupsbecause jus t as with r egular I F s tatements , you can omit the ELS Epar t, meaning you can do something li ke thi s ..: $iif($me isop$chan,Change topic): { topic $chan $$ ?= " Enter the new topic in # $+" } T his popup would only be available when you' re op' d in a channel,allowing you to change the topic of the channel. $iif i s also good forproducing messages where most of the words are similar, changingonly a word or two depending on the user ' s input or other condit ionssuch as channel modes or awaystatus...

    Another examplealias bdeg {

    if ($2 = = c) { retur n $round($calc(($1 * 1.818 ) + 32),1 ) } els eif ($2 = = f) { return $r ound($calc(($1 - 32) * 0.55), 1) } els e { return I nvalid input }}T his is a cus tom identifier that conver ts Cels ius degrees to Fahrenheit,and vice versa. Usage is $bdeg(N,C/F), N is the number of degrees toconvert, C means that this number is degrees Celsius and should beconver ted to Fahrenheit , whereas F. .. . well , you know : )

    Looking at l ine one, the if s tatement ($2 = = c) says that I F word2 is c,T HEN return the number in word1 fi r s t multiplied with 1.8 18 , thenadded to 32, then r ounded to 1 decimal. T his wil l be the degrees inFahrenheit.Line two says ELS E I F word2 is f, T HEN retur n the number in word onesubstracted with 32, then multiplied with 0.55, then rounded to 1decimal. Wi th these two lines , we' ve got ourselves functions that canconver t the temperatur e, the thi rd line says I F NONE of the above istr ue, T HEN return I nvalid input, as an er rormessage.T es t this yours elf, //echo -a $bdeg(32,F)should return 0.0,$bdeg(0,C)should return 32.0, and $bdeg(88,F)should return 30.8.

    Conclusion

    We' ve in thi s li ttle ar ticle gone thr ough one of the most impor tantfeatur es of any coding, the I F- T HEN-EL S E s tatement, and seen how itallows us to create code that r eacts conditionally on the envi ronmentand the user ' s input. Note that in the case of s ingle line if s tatementsor execute sections, the ( )' s around the I F s tatement and the{ }

  • 8/10/2019 eBook Irc & MIRC Commands

    35/62

    around the execute code is not needed, but it' s s ti ll however generallyrecommended, as it ' s supposed to speed up the par s ing of suchs tatements and also produces eas ier- to- read code.Als o note that each code snippet needs the same number of opening {and closing } brackets, missing opening or closing brackets may result

    in code that' s not executed in the corr ect order , is executed at thewrong time or j us t wr ongful ly executed in general. You can often spotthi s in your r emotes i f the beginning of an alias , r emote or popupdefinit ion is indented (not quite to the left of the editor window). T o

    check for bracket mismatches, you may als o pres s the button, thi swill usually take you to the area where a bracket mismatch erroroccur s .I hope you now have a li tt le clearer unders tanding of what i f- then-els eis and how to use it, feel free to emailus and tell us what' s s till unclear: )

    L oops

    Welcome to this lit tle ar ticle on one of mI RC scr ipting' s mos t us efulfeatures, the ability to loop.

    Prerequirements for this article is knowledge of IF -THEN-ELSE, aliases ,identifiers and variables.

    W hat ar e loops?A loop is a piece of code that r epeats its elf for as long as we decide,the end or the beginning of the loop has instructions that causes theloop to know when it s hould jump to the beginning of the loop' s code,and repeat once more.Without loops , i t' s unlikely that computers and programming wouldhave come very far . L et' s look at a s imple alias that l is ts all channelsyou' re on. Fi r s t without the use of loops :

  • 8/10/2019 eBook Irc & MIRC Commands

    36/62

    alias chlist { echo -a I ' m on $chan(0) channels : if ($chan(1) != $null ) { echo -a Channel 1 i s $chan(1) } if ($chan(2) != $null ) { echo -a Channel 2 i s $chan(2) } if ($chan(3) != $null ) { echo -a Channel 3 i s $chan(3) }

    if ($chan(4) != $null ) { echo -a Channel 4 i s $chan(4) } if ($chan(5) != $null ) { echo -a Channel 5 i s $chan(5) } if ($chan(6) != $null ) { echo -a Channel 6 i s $chan(6) } if ($chan(7) != $null ) { echo -a Channel 7 i s $chan(7) } echo -a End of channel li s ting}T hen the s ame command with a W H I L E loop:alias chlist2 { var% max = $chan(0), % c = 1 echo -a I ' m on % max channels : while (% c < = % max) { echo -a Channel % c is $chan(% c) | inc % c } echo -a End of channel li s ting}I f you' ve gotmI RC 5.70 or above, you can use the WHI LE loop' d codein chlist2 instead of chlist, which hardcodes everything. Even if you usean ear lier ver s ion than 5.70 , you can stil l loop, us ing GOT O loops . I ' llget back to this later on, for now let' s quickly observe the mainadvantage with loops : FAR s maller code.

    S o how does i t w ork?

    T he technique of looping takes advantage of dynamic elements in codesuch as variables and identifiers, looking at the earlier examples, allthe lines in the listing was equal except for the numbers 1 - 7. Loopsare ideal for purposes like listing or performing a line of functions thatare almost exactly similar.Wether you use WHI LE loops or the older form, GOT O loops , t hest ar t ing point of a loop is an I F st atementthat determines howlong the loop will run. Let' s look at both forms of loops a li ttle closer.

    GOT O loops

    For year s this was the only option for mI RC scr ipter s to create loops ,and because mI RC scr ipting is what it is , GOT O loops are s ti ll us ed bysome people. T he syntax of a GOT O loop is as follows:

  • 8/10/2019 eBook Irc & MIRC Commands

    37/62

    header { < some code> : target I F (if s tatement){ commands to per form per re- iteration

    inc % counter GOT O target } < some code>}T he key elements here is the : target, the I F s tatement, the inc% counter and the GOT O target. T he : target is li terally a target in thecode that can be reached by us ing the GOT O command, the I Fstatement is what will eventually stop the loop from reiterating, andthe inc % counter is the command that gives dynamic to the loop. Let' ssee how the example fr om above would look us ing a GOT O loop.alias chlist3 { var % max = $chan(0), % c = 1 echo -a I ' m on % max channels : :top if (% c < = % max) { echo -a Channel % c is $chan(% c) | inc% c |gototop} echo -a End of channel li s ting}As we see, not that different. T he : top target i s the star ting point ofthe loop (note that the line above only is showed once, thus it ' s not in

    the loop), aside from specifying the target and using goto top at theend of the loop, all the lines are s imilar to a WHI LE loop. E ach : targetmust be unique for the alias/popup/remote that called it, meaning ifwe wanted another loop within the loop in chl is t3 , we would need tocall the target s omething els e, for ins tance : top2. Als o note that whilewe specify the target' s location in the code with : targetname, we useonly goto targetname when us ing goto to jump to that target.Goto loops is what you have to settle for if you' re us ing mI RC 5. 61 orear lier , but for mI RC 5.70 and newer we have a better tool, the WHI LEloop:

    W HI LE loops

    We have alr eady s een the WHI LE loop in action, in our channel li s tingalias , chlis t2. T he syntax for a WHI LE loop is as follows:

  • 8/10/2019 eBook Irc & MIRC Commands

    38/62

    header { < some code> WHI LE (if s tatement){ commands to per form per re- iteration inc % counter

    } < some code>}T he key elements in a WHI LE loop is the WHI LE s tatementit self andthe inc % counter . T he WHI LE s tatement is a regular if- then-els estatement and indicates the start of the loop, as well as determineswhen the loop should end. I nc % counter increases the control var iableand allows us to measure the progress of the loop.Let' s look at an example again, this time we' ll look at an alias thatcolors nicknames in a channel according to their status.alias ncol { var % max = $nick(# ,0), % c = 1 WHILE (% c < = % max){ if ($nick(# ,% c) isop # ) { cline 4# $nick(# ,% c) } els eif ($nick(# ,% c) is vo # ) { cline 5$nick(# ,% c) } if ($nick(# ,% c) = = $me) { cline 3$me } I NC % c }}T he fir s t line initializ es the var iables we' ll us e in the alias , the WHI LE isa s imple if s tatement that s tops the loop when the counter var iable % c

    becomes larger than % max, which is the number of nicks in thechannel. T he body of the loop cons is ts of 4 lines , line 1 colors thecurrent nickname red if he/she is an op in the channel, line 2 colorsthe nick brown/dark red if he/she is a voice, line 3 colors your ownnick green, and line 4 increases the counter var iable % c.S imple, is n' t it? = ) I f we wanted to do this without loops , we wouldhave to write an alias that would be somewhere around 50-100 lineslong, j us t to ensur e we had mids ized channels accounted for , manychannels have more than 100 us er s and our mass ive alias wouldn' twor k ful ly for these channels . Wi th a loop, you don' t have to wor ryabout how many users are in a channel, but only about writing aneffective loop to perform the tasks you need as quickly as possibly.

    L ockups

    T here' s a few things to note when us ing loops . Fir s t, things will gowrong. You wil l always encounter problems where a var iable doesn' tevaluate as you think it should, and the loop will never know when tos top, you' ve got a so-calledI nfinite loop. I f this happens, your mI RC

  • 8/10/2019 eBook Irc & MIRC Commands

    39/62

    will lock up, but fear not! For see, press ct r l+ b r e ak (the break key isus uall y located at the top r ight of mos t k eyboards , as ide the scroll lockkey) , and mI RC wil l break out of the endless loop.T he most common reason for an infinite loop is that you forget to incthe counter , which means the if s tatement always wil l be tr ue. I f you

    should get an infinite loop, your best tip is to look at the if-then-elsestatement and ensure that you are modifying the counter variable.Another thing regarding loops ; sometimes they jus t plainly take a longtime to finis h executing. I n some cases , s everal minutes . And while theloop is executing, mI RC may lock up. T his is not a problem if the looptakes only a few miliseconds to finish, but if it takes minutes, you riskthat your mI RC ses s ion is busy doing the loop and won' t r eply to theserver ' s PI NG, with a result that you get dis connected because the I RCserver thinks you' re no longer connected.T o prevent this , you can either tr y to use fas ter r outines , or you mayrun an extr a mI RC ses s ion jus t for the purpose of per forming the loop,and close it once the loop finis hes . T his way the mIRC ses s ion that' sconnected to I RC will be fr ee to do it ' s nor mal tasks .

    S peed

    I ' ve tested the speed of both GOT O and WHI LE loops with 2 s implealiases as follows:alias gspeed { var % s = $ticks, % c = 1, % max = $1 :top

    if (% c < = % max) { inc % c |goto top } echo -a Ended GOT O loop after % max r uns , in $calc($ ticks - % s )ticks}

    alias wspeed { var % s = $ticks, % c = 1, % max = $1 while (% c < = % max) { inc % c } echo -a Ended WHI LE loop after % max r uns, in $calc($ticks - % s )ticks}

    Us age is /gspeed Nor /ws peed Nwhere N is the amount of loops toperform. Note that this test only tests the speed of increasing thecounter and continuing the loop, the loop does not per form anycommands as given here. With 3 test values, 1,000, 10,000 and100,000 reiterations, the results were as follows (average of 3 runs,amount is in ticks (1,000 ticks is 1 sec)):

    1 ,0 0 0 1 0 ,0 0 0 1 0 0 ,0 0 0

  • 8/10/2019 eBook Irc & MIRC Commands

    40/62

    GOT O 140 1545 15649

    WHILE 126 1348 13681T he results sugges t that for these rather useless loops , WHI LE loopsare fas ter than GOT O loops , as much as 2 seconds fas ter on 100, 000

    reiterations . T here are many facts to consider when determiningspeed, so results for loops that actually performs any commands mayvary from this tes t, however WHI LE loops will s til l be the fas ter way.

    Conclusion

    I n thi s ar ticle we' ve been explor ing the advantages to us ing loops , aswell as looking closer at the var ious types of loops , what can we readfrom all this?Fi r s t off; us ing loops is next to always the eas iest and fas test way toperform listings or multiple similar commands at, as the results above

    show, around 1- 2 s econds for 10 ,000 runs of a loop, that' s not bad ; )S econd; WHI LE loops are fas ter and smaller in code than GOT O loops .T hus, WHI LE loops should always be used if your mI RC ver s ion isnewer than 5.70 and you are not wor r ied about backwardscompatibil ity in your scr ipt. I f you need your scr ipt to be compatiblewith ear lier ver s ions of mI RC, you wil l need to use GOT O loops .T he real tr ick to mI RC scr ipting and programming in general is asmuch to be able to see what tool is the right at what place, hopeful lywith this ar ticle you have gotten a more intimate knowledge of loopsand can s tart applying this knowledge to scr ipting problems you face : )

    R aw event s

    Welcome to this li tt le ar ticle on raw events . When talk ing about " raw" ,we either mean raw commands sent to the server (ie, /raw privmsgnickname : message goes here ins tead of /msg nickname messagegoes here), or raw events. I n bot h cases w e'r e talking about th enat ive for mat of t he I R C ser ver, rather than the way mI RC or yourclient of choice presents or uses the information. I n this ar ticle, we' llbe talking about r aw events , not r aw commands.

    Pre-requirements for this article is knowledge of remotes , identifiers ,if-then-else, and variables.

    W hat ar e r aw event s?

    Raw events are regular mI RC scr ipting events that tr igger when theserver sends you a message as a result of something you do, for

  • 8/10/2019 eBook Irc & MIRC Commands

    41/62

    instance joining a channel. When you do this, the server will a) sendyou the names on the channel (similar to /names), b) current topic ofthe channel as well as c) the channel' s creationtime.Raw events receive the information from the ser ver in it ' s native form,and gives you maximum flexibility in regards to how you choose to use

    it or present it to the user of your script.

    How do I use raw events ?

    Let' s fir s t look at the syntax of raw events :raw NUMBER :MAT CHT EXT : { commands }

    NUMBER here is the number of the numeric event you wish to define,these are set down in RFC1459which is the I RC protocol, and are als olisted more conveniently in Jeeps ter ' s numer ic helpfile. I f a raw eventdoes not have a numeric, you can specify i t' s name ins tead.MAT CHT EXT is which text s hould tr igger the event, much lik e the

    MAT CHT EXT parameter in an on text event. From /help raw events ;raw 322: * mirc* : { echo 5 $1 - }will filter out all channels matching " mirc" in a /lis t, and echo them tothe status window.T o actually * use* raw events , you need to have a fi rm knowledge ofraw events, or be able to look up information and again, for thispurpose, Jeeps ter ' s numer ic helpfile is great = ) I n addition, as somany other things in scripting and programming, most of the trick withraw events is simply seeing where they can be useful.

    A clos er look

    Let' s look at the raw output of a/who:raw 352: * : { echo -a Raw $numer ic $+ : $1- }mI RC will by default show this output (after /who # B0P' s):# B0P' s B0T H@ [email protected] RCop.com :5 B0P' s B0T -http: //mir c-egg.net# B0P' s B0P-away G@ bop@rad-pc-57 .cablenet-va.com : 0 B0P(http: //mir c-egg.net)but as alr eady s aid, this reply has been formatted by mI RC, themessage the server s ends mI RC is actually the one below:

    $1 $2 $3 $4 $5 $6 $7 $8 $9-

    B0P-away

    # B0P' s

    bopplaying.with.my.pet.I RCop.com

    lineone.uk.eu.dal.net

    B0T H@ 5

    B0P' sB0T -http: //mirc-egg.net

  • 8/10/2019 eBook Irc & MIRC Commands

    42/62

    B0P-away

    # B0P' s

    boprad-pc-57.cablenet-va.com

    liberty.nj.us.dal.net

    B0P-away

    G@ 0

    B0P(http: //mirc-egg.net)

    T his isthenick oftheuserrequestingthe/who.

    Thisisthetargetforthe/who

    Thisis thecurrentlyreturnedus er ' sidentd

    T his is the hostofthe currentlyreturned user.

    T his is theserver theuser isconnected to.

    Thisistheus er ' snick.

    Thisrepresentsstatusin thechannel aswell asaway/not.

    This

    is thenumber ofhops(serversbetweenyouandtarget)

    T his i stherealnameentry

    Let' s make a channel s tats scr ipt and see if an example makes itclearer : )

    Channel st at s example

  • 8/10/2019 eBook Irc & MIRC Commands

    43/62

    alias cs tat { set -u20 % bcs .target $active |s et -u20% bcs .352 1 | .who % bcs .target }

    raw 352:* : { if (% bcs .352) {

    haltdef inc % bcs .total if (Gis in $7 ) { inc % bcs .gone |set % bcs .anicks% bcs .anicks $6 } if ($chr(64) is in $7) { inc % bcs .ops } els eif ($chr(43) is in $7) { inc % bcs .voice } if ($chr(42) is in $7) { inc % bcs .ir cop | set% bcs .nicks % bcs .nicks $6 } inc % bcs .hops $8 }}raw 315:* : { if (% bcs .352) { haltdef var % regs = $calc(% bcs .total - (% bcs .ops +% bcs .voice)) echo -ea Channel s tats for % bcs .target $+ : echo -a T otal user s : % bcs .total echo -a Away user s : % bcs .gone ( $+$r ound($calc((% bcs .gone * 100) / % bcs .total) ,1 )$+% $+ ) $i if(% bcs .anicks ,- [ % bcs .anicks ] )

    echo -a Op' s : % bcs .ops ( $+$r ound($calc((% bcs .ops * 100) / % bcs .total),1) $+ %$+ ) echo -a Voices : % bcs .voice ( $+$r ound($calc((% bcs .voice * 100) / % bcs .total) ,1 ) $+% $+ ) echo -a Regular s : % regs ( $+ $ round($calc((% regs* 100) / % bcs.total),1) $+ % $+ ) echo -a I rcop' s : % bcs .ir cop ( $+$r ound($calc((% bcs .i rcop * 100) / % bcs .total) ,1 ) $+% $+ ) $iif(% bcs .nicks ,- [ % bcs .nicks ] ) echo -a Average hops : $round($calc(% bcs .hops /(% bcs .total -1)) ,1)

    .timer 1 2 unset % bcs .* }}T his is a pretty s imple and unformatted scr iplet but i t s hows you howyou can use raw' s for practical purposes . R aw 352 is the raw for each

  • 8/10/2019 eBook Irc & MIRC Commands

    44/62

    /who output, raw 315 is the raw for " end of /wholist", we use raw 352to gather information about each us er, and when we receive raw 315,we know that there' s no more users to gain information about, so wecan present the output to the user . T his scr iplet als o shows how wecan us e haltdef (or even halt) to prevent the default output from

    showing up, i f we didn' t do this , the user would see the output of the/who as well as the nice channel s tats .T he more you s cr ipt with r aw events , the more you' ll realiz e both howsimple it is, as well as how much it means to be able to see that this orthat can be done by us ing raw events . For ins tance, a commonmistake in scripting is when the scripter wants the script to take actionbased on what channels a different us er is on (a so called pervscan),he uses the if-then-else operatorI S ON to determine if the user is on acer tain channel or not. I S ON is fine if the user running the scr ipt is onthat channel too, but in mos t cases , he won' t be, and that' s where rawevents come in again.

    Another example, the Bad Channels kicker

    Cur rently the only way to know what channels a specific nickname onI RC is on, i s doing a /whois on them. I S ON won' t do it, because asalr eady s tated; I S ON reacts only on channels you are on yourself. S owe have to use /whois somehow to determine the channels the user ison. T here' s several problems that ar is es here, let' s try to nar row itdown a little:Firs t, let' s f ind outw hich r aw event s t r igger s on a w hois( there' s a

    lot!). I s tated previous ly that two major sources for more info on rawevents was the RFC, as well as Jeeps ter ' s numer ic helpfile. For mos tscr ipting purposes , Jeeps ter' s helpfile is by far the eas ier choice, s odownload it i f you haven' t and s tar t looking.. : )Double clicking numeric.hlp opens up a dialog showing the help topicsavailable, choose "Contents " . Now click on " Numeric Code" (F as treference). T his opens up the very handy quickl is t for frequently us edraw' s , under T opical Numer ics we seeWHOI S listed. Bingo! ClickWHOI S . T his opens up the helpfile on S er ies 300 Command replies , onraw 311. Raw 311is the raw containing our " real name" entr y, andhere indicates the star t of the WHOIS replies . Wi thout any more

    ceremony; raw 311, 312, 317, 318, 319 . I n addit ion you may als o seeraw 301(away), 307(dalnet - registered nick), 313(is an ircop).Looking over the events, we quickly see that raw 319 isR P L _ W H OI S CH AN NE L S ; it retur ns the channels the user specified ison. We also see that raw 318 is end of w hois, useful to know forwhen we wil l be taking action based on the channels in r aw 319.We do not need to us e any information retur ned by any of the otherraw' s from the WHOI S , s o we will just s ilence these us ing/haltdef, to

  • 8/10/2019 eBook Irc & MIRC Commands

    45/62

    make sure our script is looking neat. For simplicity here, we will justkick the user from the channel we specify if his channels matches anyof the keywords we will look for. We will also write the keywords tomatch the channels against in the code itself, instead of leaving this upto the user, this can be modified using $reador storing keywords in an

    .ini file or in variables. F ir s t, let' s look at a typical output of r aw 319:r aw 3 19 :* : { echo -a $1 - } I typed /whois B0T and got this output back...:B0PB0T @# mystr o @# B0P' s @ # scriptech @# hdtest @# HD-Helpers@# Kors farer @# Mirc_ Resources @# B0Ptes tAgain, $1is the nick of the requester (you), $2is the target, B0T , and$3- contains the channels the target is on.Us ing this , let' s move on to creating this kicker.

  • 8/10/2019 eBook Irc & MIRC Commands

    46/62

    alias chanscan { if ($active is chan) { set -u15 % bps .chan $active } els eif ($2 i schan) { set -u15 % bps .chan $2 } ; s tores the channel to kick the user fr om in a var iable set -u15 % bps .319 1

    .whois $1}

    raw 311: * : { if (% bps.3 19) { haltdef } }raw 312: * : { if (% bps.3 19) { haltdef } }raw 317: * : { if (% bps.3 19) { haltdef } }raw 301: * : { if (% bps.3 19) { haltdef } }raw 307: * : { if (% bps.3 19) { haltdef } }raw 313: * : { if (% bps.3 19) { haltdef } }; prevents the normal output from the /whois being shown

    raw 319:* : { if (% bps.31 9) { haltdef if (* warez* iswm $3- ) ||(* sex* iswm $3-) { set -u10 % bps .found 1 ; one of the channels the user is on is containing the wordwarez or the word sex } }}

    raw 318:* : { if (% bps.31 9) { haltdef if (% bps .found) { kick % bps .chan $2 I don' t like yourchannels! } ; if the var iable was set in raw 319, the user is in one or morebad channels, kick him. els e { echo - s $2 was not in any bad channels } } .timer 1 5 unset % bps .* ; thi s should be more common in s cr ipts . Clean up var iables afteruse.}Now type /chans can B 0Pin any channel to kick B0P from that channelif he' s in any channels containing the words " sex" or " warez" . T he aliassets the channel to kick the user from, and sets the cont r olvar iable% bps.3 19to use later in the raw events, if this variable is set, we will

  • 8/10/2019 eBook Irc & MIRC Commands

    47/62

    halt the default output from the event and in some cases present ourown. Finally the alias does a /whois on the nick entered.Raw 319 matches the channels in $3- agains t the words " warez" and"sex", and if found, it sets a variable that is carried into raw 318 (endof whois). When raw 318 triggers, it checks to see if the variable is

    set, if it is, it kicks the user specified, else it lets you know that theuser was not in any bad channels.

    Conclusion

    While not among the mos t obvious featur es of mI RC scr ipting, learninghow to use raw events is one of the most valuable things you can do,it' s easy, allows you to do many things you otherwise wouldn' t be ableto (such as the channelscanner), and is also an interesting tool formodifying the look and feel of mI RC. T o effectively us e it; a decentknowledge of raw events in general and being able to look up which

    event does what, wil l sur ely come handy, and I hope this ar ticle havegot you started on the task of mas ter ing raw events . Good luck : )

    Cust om W indows

    Before dialogs was int roduced in mI RC 5.50, the main way to make agraphical user inter face GUI for your user s was custom windows, andtheir cousins, picture windows (which just is a kind of custom window).T hey were not as s imple and intui tive to use as dialogs , but the good

    scripters could make good interfaces that would outshine any dialog,and even today there' s several things a cus tom window can do that adialog cannot. T his ar ticle in specific won' t teach you window wiz ' sanything sensational, it ' s a mere introduction to the wor ld of customwindows, take it as that. Let' s move on to the good s tuff : )

    Opening a custom window

    T o open a cus tom window, us e the /window command. You' ll findyourself using that command a whole lot, almost everything that

    modifies, creates or closes a custom window is done with thatcommand and it' s var ious switches . T ype/window @testto open up awindow called @tes t . Whee! T o add text to it, /aline @test testingor/echo @test testing= )We' ve now opened a cus tom window, and we' ve added text to it . B ut i fthat was all , cus tom windows would be bor ing quite fr ankly. Let' s lookat a few ways to modify the look of your cus tom window : )

  • 8/10/2019 eBook Irc & MIRC Commands

    48/62

    Add text to the tit lebar : /titlebar @test T his is a tes t: )Remove @ in front of the windowname /window -k @test(can als o beus ed when opening)Create an editbox for window /window -e @test(onlyworks whenopening window)

    Open window on the desktop (not a par t of mI RC), /window -d @testPlace desktop window on top of other windows, /window -o @testRename a cus tom window, /renwin @ oldname @newname [topic](topic optional)Close a cus tom window, /window -c @test

    Adju st ing siz e and posit i t on of a cus t om w indow

    /window [-abcdeEfg[N]hk l[N]noprswx] [ - tN,. .,N] [+ bdeflLmnstx ]< @name> [x y [w h] ] [/command] [popup.txt] [font [size]] is whatthe mI RC helpfile specifies for the /window command' s syntax. T o

    modify s ize and pos it ion of the cus tom window, we' ll use thex y w hparameter s = )Xand Yis the window' s pos ition in the mI RC main window, 1 1 wouldspecify that you wis h to open the window in the upper left corner ofthe main mI RC window. By increas ing the s izes , you' ll move thewindow further to the right and down. Wand His the width and heightof the window, be aware that small sizes may not give any differentoutput than no sizes at all, you may wish to specify sizes above 50 forwidth and height each.

    An example/window -dhlk - t7,23 ,39,55 ,71 @ RawCapture 1 90 6 00 200 @Rc Ar ial9T his command wil l open a window much li ke the one here.. :

  • 8/10/2019 eBook Irc & MIRC Commands

    49/62

    Let' s look at what thi s command does . T he-dswitch first specifies thatthis will be a desktop window. While you cannot see this at thescreenshot, this window is indeed a desktop window. -hhides thewindow from the mI RC taskbar , -kremoves the @ prefix in thewindowname (as we' ve alr eady mentioned), and- lspecifies that we' reopening a li s tbox window. T he reasons for opening a window as alistbox window can be various, in this specific instance it is to enablethe use of tabs in the window, which is what the -t7,23etc par t i sabout, it sets the tabstops for the window.

    @RawCaptureis of course the window' s name, and1 90specifies Xcoordinate 1 ( to the far left of the mI RC window), Y coordinate 90,which in this example quite unelegantly makes the window cover themI RC taskbar . 600 200specifies 600 in width for the window, and 200in height. We see that relatively to the main mI RC window, 200 doesnot mean a very huge window. @Rcafter this means " use the cus tomwindow menu with name @Rc" , we' ll come back to this in a little while,and finally, Arial 9specif ies the fonttype and s iz e for our window = )

    Makin g a menu f or a cus t om w indow

    You have two ways of making menu' s for a custom window, either bymaking a plain textfilewhich contains the menu' s you wis h to add, orby specifying the menu' s dir ectly in the remote file. T he methodspecif ied in the above example was the latter, s pecifying the menu' sdir ectly in the remote fi le. I f you would do it the other way, you wouldneed to s pecify filename.txt ins tead of the @Rc(or the name of the

  • 8/10/2019 eBook Irc & MIRC Commands

    50/62

  • 8/10/2019 eBook Irc & MIRC Commands

    51/62

    out other selections, similar to pressing ctrl when selecting files inWindows Explorer. -hwill highlight the window' s icon if it' s minimized,useful for use in scripting when you wish to have some way of tellingthat a window has been modified when minimized. Finally, the -pswitchwill force text that is added using i l ine, aline or r l ineto be

    wrapped to the next l ine, if it ' s too long to fit the window (otherwisethe text will simply disappear to the right end of the window).

    I dent if ier s and s uch

    I f you wis h to for ins tance save the pos it ion of a window, to ensurethat the window will reappear in the same position and with the samesize as when you saved it last, you can take advantage of the customwindow specific identifiers, for this purpose, $window. $window hasseveral additional properties, but the basic syntax is$window(N/@name). N will be the N' th window, or els e you can specify

    a windowname to return the properties for that window in specific. Youcan use $window to for instance check if a custom window exists ornot; $window(@test)will return @test if the window exists, and $null ifi t doesn' t.You would think that $window(0)would return the number of opencustom windows, but actually that will return the number of openwindows (including chats and channels ) in mI RC. T o retur n the numberof open cus tom windows, we' ll take advantage of the abil ity to specifya wildcard for the windowname, and us e $window(@ * ,0). You can als ouse this as $window(@t* ,0)to return the number of custom windows

    with a name starting with t open.Proper ties of $window are many, and I won' t go into detail of all , buthere' s a few of them..:x,y,w,hXand ycoordinates of the upper left corner of the window,while wand his the width and height of the window. Usage would be$window(@test).xto get the x coordinate of @test, or$window(@bleh).wto get the width of @bleh.statewill return the state of the window, can be used to ensure that awindow opens up instead of staying minimized if something shouldhappen that you wish to make the user aware of. state will returneither min imi zed, maximiz ed, nor mal or hidden. S o to activate a

    minimized window if something happens, you could do if($window(@tes t). s tate = = minimized) { window -a @tes t }titlewill return the text in the titlebar of a window (ie,$window(@test).title).fontreturns the font used in the window, useful if you wish to make forinstance a setup dialog that allows the user to select font for yourscript. Works together with the fontsizeproperty, which returns the

  • 8/10/2019 eBook Irc & MIRC Commands

    52/62

    fontsize used in the window. fontboldals o works in this par t, r eturning$true if the window is using a bold font, otherwise $false.

    Ot her ident if i er s include

    $l ine(@ name,N,T )which retur ns the N' th (fr om above) l ine of text in

    the window specified, if you choose 0 for N, it will return the number oflines in the window (us eful for loops : )) T is there so you can have theidentifier working on the s ide lis tbox (if one exi s ts ), if T is 0, it will usethe regular dis play area, if T is 1 i t will us e the s ide- li s tbox. T isoptional.$fl ine(@ name,wildtext,N,T )Returns the N' th line where wildtext isfound, again counted from the top. Wildtext is literally wildcard text,$fline(@test, bleh* ,0 ) will return the number of lines that s tar t withbleh, whereas $fline(@test,* what* ,2) will r eturn the 2nd line from thetop that has whatin it somewhere (starting with, ending with orcontaining what). Again, T is optional and works s imi lar ly as for $l ine.

    $sline(@name,N) Returns the N' th s elected line in a li s tbox window($s line only works in lis tbox windows). I f N is 0, $ s line will return thetotal