project: irc scripting


have you ever been in a chat with someone who has one of those annoying pr0gz that tells you what song they're listening to or the like? irc has its own built-in scripting language, allowing you to create your own customized functionality (or robot). in this project i will cover a few basics. you can find a detailed overview in the help file (just check the index for "scripting").

all mirc remote scripts are stored in plain-text (ascii) files and must be loaded into mirc before they can be used. to load, unload, quickly edit a script, and see what scripts are currently loaded, you can use mirc's built-in script editor, which can be accessed under the tools menu (or by hotkey alt+r).

an "alias" is a command you create to represent another (usually longer) command or set of commands. for example, an alias to quickly find people in illinois is:

 alias il {    /who *il.ameritech*   /who *uiuc.edu*   /who *isu.edu*   /who *soltec.net*   /who *il.da.uu.net*   /list *illinois* } 

this would be typed in the "remote" tab of your irc script editor. here, an alias command "/il" is defined as 6 other commands that will execute in succession when /il is called. so whenever i enter /il into mirc, it will list all non-invisible users with the above listed regional isp domains in their whois info. then it will search for all channels with the string "illinois" in their names. a popular alias especially for channel operators is a single command to ban and then kick someone from a channel. this is a typical kickban alias:

 alias kickban {   /mode # +b $1   /kick # $1 $input(enter reason:, 1) } 

this alias is called with an argument (parameter); in this case, the name of the user you want to ban. the first argument is referenced (much like in dos batch files and unix scripts) by $1. if there were two arguments needed for an alias command, the second argument could be used by referencing (you guessed it) $2. easy, huh? the channel name is referenced by just a hash (#) in the script. so we call this particular alias command by typing "/kickban [nick]". the "/mode" command is called with the proper channel name and nick of the person to be banned. then something interesting happens: before /kick is executed, it requires its own arguments. we already know two of them: the channel name and the nick of the person to be kicked, but to get the third, the reason for the kick (the text the kickee gets on his/her way out), the script pops up an input dialog. the $input function allows for a popup dialog with the first function parameter being the prompt and the second parameter being the dialog type. here, we prompt for a string of text to be our kick reason. once the reason is input, the /kick command executes.

you can also code some automatic reactions to "events." events such as someone in the same channel saying something with a certain keyword, someone joining or leaving a channel, or receiving a private message are just a few common examples. let's take a look at some code. if you were insert the following in your irc script editor, whenever anybody aside from you types "flip" it will respond with either "it's heads!" or "it's tails!"

 on 1:text:flip*:*: {  $iif($rand(1,2) == 1, describe # it's tails!,describe # it's heads!) }  

the above is all one line, non-formatted for simplicity. as you can see, there are a lot of different possibilities for automation here: have fun.




Tapeworm - 1337 Hax or Handbook
Tapeworm - 1337 Hax or Handbook
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 74

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net