A simple reply to a RAW event that I've set fore an example below coresponds to the numeric reply 322, which is the standard server reply to the /LIST command, used to list the names of the channels on the net you are connected to. This example uses an asterisk <*> for the match text parameter, and then prints whatever text it receives from the server to the mIRC Status window.
RAW 322:*:{ echo -s $1- }
Note: Most of the events raised by the server seem to send several replies, further more if the information the server supplies is too big to fit within one line. In our example, that coresponds with as many server replies as there are channels. That's why, in order for the client to recognize the start and the end of the list of information that the server supplies, most of the numeric replies are related to similar repliesarking the start and the end of the list. According to the RFC1459 protocol:
Numeric Reply: 321 RPL_LISTSTART
Server Text: Channel :Users Name
Numeric Reply: 322 RPL_LIST
Server Text: <channel> <# visible> :<topic>
Numeric Reply: 323 RPL_LISTEND
Server Text: :End of /LIST
Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark the start, actual replies with data and end of the server's response to a /LIST command. If there are no channels available to return, only the start and end reply must be sent.
We do not neccesarilly need to filter the replies marked with 321 and 323, but they offer an oportunity for initialisation events, especially if you want to print the replies to a specific window. For that to work, we'll set our example to list the channels in a different custom window, which will be created bu using the /WINDOW command.
RAW 321:*:{
if ($window(@CHANNELS) == $null) {
window @CHANNELS
aline @CHANNELS Listing all available channels ...
}
}
RAW 322:*:{ aline @CHANNELS $1- }
RAW 323:*:{ aline @CHANNELS Finished listing channels ... }
As you can see, the code is quite simple. In the first RAW event, the RPL_LISTSTART is processed. The script checks if a window has been opened. If not it opens a custom window named @CHANNELS, which does not have a listbox nore an editbox, simply cause they are not needed, and then prints the line Listing all available channels ...
The second RAW event processes the listing action itself. For every reply the client receives, the script prints a line in the @CHANNELS window according to the RFC1459 format tha has been set within the reply: <channel> <# visible> :<topic>.
The third RAW event simply announces the end of the channel listings.
Note: Even though the RFC1459 protocol, and therefor the servers cover every event that can be raised with a specific numeric reply, try to use the RAW events filtering and handling in situations that can not be avoided, such as the one described before. That is why, mIRC has been programmed to anticipate most of the events by not coresponding to the RAW events.
In addition to the tutorial is a script that, just like the one before, prints the MOTD to a custom window by using the specific replies.
Message Of The Day Anticipation
Numeric Reply: 375 RPL_MOTDSTART
Server Text: :- <server> Message of the day -
Numeric Reply: 372 RPL_MOTD
Server Text: :- <text>
Numeric Reply: 376 RPL_ENDOFMOTD
Server Text: :End of /MOTD command
When responding to the MOTD message and the MOTD file is found, the file is displayed line by line, with each line no longer than 80 characters, using RPL_MOTD format replies. These should be surrounded by a RPL_MOTDSTART ( before the RPL_MOTDs ) and an RPL_ENDOFMOTD ( after ).
RAW 375:*:{
if ($window(@MOTD) == $null) {
window @MOTD
aline @MOTD Printing the Message Of The Day at server $3 ...
}
}
RAW 372:*:{ aline @MOTD $2- }
RAW 376:*:{ aline @MOTD Finished MOTD ... }
Note: Unlike the previous example, I used the $2- parameter because I tried to avoid the :- mark to be displayed.