IRC Raw Numerics
What are raw replies?
Any time you ask an IRC server some type of question, it will send you a reply. It can't send back plain data though, it has to code it in some way so that the IRC client can understand
what the data is for. Confused? A simple and would be if you tried to join a channel but couldn't get in, The server would reply with this string:
The rest of the string will contain information pertaining to the reply. The rest of the string in the above example is telling us what channel we tried to join that was invite only.
:irc.core.com 473 _Yeti_ #mIRC :Sorry, cannot join channel.
The first section is the server that is replying to you. This can come in handy, as you will sometimes receive a reply from a server your not on. The next portion, 473, is the actual
numeric. The message the server sends us tells us we can't get into the channel, but why? 473 is the reply for "Channel is invite only". There are other similar error codes, such as 471
for "Channel is full", or 474 for "You're banned"
The rest of the string will contain information pertaining to the reply. The rest of the string in the above example is telling us what channel we tried to join that was invite only.
What can I use numerics for?
The main use that most people use raw events for is to customize the way their information is printed out, though there are many uses. You can change
the way your /whois is printed out, customize error messages, gather ban list information, and much more.
Raw Events
Raw events work just like other mIRC events, such as on join, on kick, on text, etc. They are triggered by
something that happens, and go in your remote section. The format is slightly different then a regular event though, and looks like this:
In the example above, we could echo that error by doing this:
To fully understand how to use raw events, you must first understand the parameters. You use $1, $2, $3, etc, just like you do in an alias. $1 would be the first 'word' in the servers reply, $2 would be the second, and $1- would be the full reply. One thing to note is that EVERY reply from the server will always contain your nickname, so $1 is always your nickname.
On other thing to note is that you must use the /halt command if you don't want mIRC to print out its normal text in relation to a raw event. I've added the halt command on my example so that only my message is displays, and mIRC hides its own standard error reply.
A very useful technique for learning raw events is to add this to your remote section:
This will trigger any time a raw event goes off, and will print out all the information to your status window for you to study. If you plan to customize the way mIRC looks, this will also let you catch any of the raw events that you didn't script for. One other magic identifier that you can use in raw events is $nick, which will tell you the server that sent the reply.
Before we get into some full fledged examples, you may want to start by downloading the Numeric Help File. This will detail all of the codes that are out there, so you can look it over to see what your capable of doing with raw. The information there is designed primary for the EFnet network, and has not been updated for a while. If you normally use another network, or are trying to take advantage of new server features, you may not find the information in the help.
raw <numeric>:matchtext: { commands }
In the example above, we could echo that error by doing this:
raw 473:*: echo -a I tried to join $2 but its invite only! | halt
To fully understand how to use raw events, you must first understand the parameters. You use $1, $2, $3, etc, just like you do in an alias. $1 would be the first 'word' in the servers reply, $2 would be the second, and $1- would be the full reply. One thing to note is that EVERY reply from the server will always contain your nickname, so $1 is always your nickname.
On other thing to note is that you must use the /halt command if you don't want mIRC to print out its normal text in relation to a raw event. I've added the halt command on my example so that only my message is displays, and mIRC hides its own standard error reply.
A very useful technique for learning raw events is to add this to your remote section:
raw *:*: echo -s $numeric $1-
This will trigger any time a raw event goes off, and will print out all the information to your status window for you to study. If you plan to customize the way mIRC looks, this will also let you catch any of the raw events that you didn't script for. One other magic identifier that you can use in raw events is $nick, which will tell you the server that sent the reply.
Before we get into some full fledged examples, you may want to start by downloading the Numeric Help File. This will detail all of the codes that are out there, so you can look it over to see what your capable of doing with raw. The information there is designed primary for the EFnet network, and has not been updated for a while. If you normally use another network, or are trying to take advantage of new server features, you may not find the information in the help.
Whois Example
One of the most common uses for raw is to capture whois information. When you do a /whois, the server sends several replies at
once. These can all be captured and manipulated as you please. First, add our previous example to your remote:
Now, whois yourself. You should get a display similar to this in your status window:
We'll start with the first line. it tells me that my hostname and real name are contained in raw 311. As I mentioned, $1 is the first word, and is ALWAYS your nickname. As you can see, i used a second client to /whois the first one. $2 in this example would be _Yeti_, as was the target of the whois. $3 contains my ident, yeti. $4 is my hostname. That * is a 'word' by itself, so $5 would contain a single *. $6 and on would be whatever was in my real name field. The get it all, you would use $6-
You may have noticed that this is slightly different from way mIRC would print out whois information. For instance, you get [email protected] in a regular whois. Your script would have to do a bit of work here to combine the ident and the host. If you wanted to customize this info, you could do something like this:
You can do whatever you want with the information contained in raw events. I could store the information in variables, write it to a file, or just stop it from printing completely. You can add colors to the echoes, flip and bend it however you want basically.
I'll skip to the idle information now, as the way the server send it may seem rather odd. The first number there, 529, is the number of seconds idle. You can use $duration to convert this to something readable. The second number is a timestamp of when I logged on. That can also be converted to something more readable with $asctime. Heres an example:
In my case, it would print out:
raw *:*: echo -s $numeric $1- | halt
Now, whois yourself. You should get a display similar to this in your status window:
311 Yeti`` _Yeti_ yeti slacker.to * Sasquatch
319 Yeti`` _Yeti_ @#Yeti @#mIRC
312 Yeti`` _Yeti_ irc.core.com The Marklar for Marklars on Marklar.
317 Yeti`` _Yeti_ 529 955689355 seconds idle, signon time
318 Yeti`` _Yeti_ End of /WHOIS list.
I get 5 separate replies from my /whois. Some may not be present at all times. For instance, if I part all channels, raw 319
will not trigger. If the server doesn't care to share my idle time, raw 317 would be missing. If I suddenly became an IRC oper,
raw 313 would show up.319 Yeti`` _Yeti_ @#Yeti @#mIRC
312 Yeti`` _Yeti_ irc.core.com The Marklar for Marklars on Marklar.
317 Yeti`` _Yeti_ 529 955689355 seconds idle, signon time
318 Yeti`` _Yeti_ End of /WHOIS list.
We'll start with the first line. it tells me that my hostname and real name are contained in raw 311. As I mentioned, $1 is the first word, and is ALWAYS your nickname. As you can see, i used a second client to /whois the first one. $2 in this example would be _Yeti_, as was the target of the whois. $3 contains my ident, yeti. $4 is my hostname. That * is a 'word' by itself, so $5 would contain a single *. $6 and on would be whatever was in my real name field. The get it all, you would use $6-
You may have noticed that this is slightly different from way mIRC would print out whois information. For instance, you get [email protected] in a regular whois. Your script would have to do a bit of work here to combine the ident and the host. If you wanted to customize this info, you could do something like this:
raw 311:*: { echo -a Whois Info for $2 - Hostname: $3 $+ @ $+ $4 - RealName: $6- | halt }
You can do whatever you want with the information contained in raw events. I could store the information in variables, write it to a file, or just stop it from printing completely. You can add colors to the echoes, flip and bend it however you want basically.
I'll skip to the idle information now, as the way the server send it may seem rather odd. The first number there, 529, is the number of seconds idle. You can use $duration to convert this to something readable. The second number is a timestamp of when I logged on. That can also be converted to something more readable with $asctime. Heres an example:
raw 317:*: { echo -a $2 logged on $asctime($4) and has been idle for $duration($2) | halt }
In my case, it would print out:
Yeti_ logged on Fri Apr 14 00:15:55 2000 and has been idle for 8mins 49secs
raw 318 is somewhat common among many events as well. This is just the server telling you its done sending information. For
instance, when you join a channel, the servers send you all the users nicknames. When its done, it send an extra raw to
say "Thats everyone, I'm done now". You can use this is a way to ensure that you have received all the information you need.Banlist Example
Another common request for raw events is to process bans in a channel. This can be used to maintain your own custom internal banlist,
or to clear all the bans on a channel. Just like /whois, you have to ask the server to send you information. To get a banlist,
simply type /mode #channel +b. When I do this, I get this output:
Again, $1 is going to be your current nickname. $2 is going to be the channel that you requested the list for. $3 is the hostname that is currently banned. $4 tells you who set the ban, and $5 contains a timestamp of when it was set. You can use $asctime again to convert this to something readable.
A simple way to clear all the bans would be to do this:
As the information on each ban was received, you could grab the hostname and remove the ban. However, if there are 10 or 15 bans, this can get quite messy! Here's a more complicated version that would allow you to do 4 at a time.
So.. how does it work? As we receive each ban, we are adding the hostname to a variable called %bans. After we add the host, we see how many we have stored. If there are 4, we clear out 4 at once, then delete the variable. The next time around, we have an empty variable and try and add 4 more again.
In case you have an odd number of bans, we also have to check one last time as the ban list is finished. Since we only wipe bans every time we get 4, the above script would never unset them if there were only 3 bans. Once the server tells us that we have the ban list, we verify if %bans exists. if it does, we still have one last batch to get rid of. To avoid errors from the server, I used $str to repeat the b enough times to cover each unban. We could specify -bbbb, but the server might complain if you tell it your going to do 4 unbans and then only specify one hostname. The last thing we do is unset out %bans variable, and we're done!
367 Yeti`` #Yeti *!*@*.test2.com [email protected] 955710688
367 Yeti`` #Yeti *!*@*.test.com [email protected] 955710688
367 Yeti`` #Yeti *!*@*.lamer.com [email protected] 955710688
368 Yeti`` #Yeti End of Channel Ban List
In this example, you see that the server sends multiple replies for the same number. Many events will do this, like /who, /names, etc.
There is also an extra event indicating that the list is complete.367 Yeti`` #Yeti *!*@*.test.com [email protected] 955710688
367 Yeti`` #Yeti *!*@*.lamer.com [email protected] 955710688
368 Yeti`` #Yeti End of Channel Ban List
Again, $1 is going to be your current nickname. $2 is going to be the channel that you requested the list for. $3 is the hostname that is currently banned. $4 tells you who set the ban, and $5 contains a timestamp of when it was set. You can use $asctime again to convert this to something readable.
A simple way to clear all the bans would be to do this:
raw 367:*: mode $2 -b $3
As the information on each ban was received, you could grab the hostname and remove the ban. However, if there are 10 or 15 bans, this can get quite messy! Here's a more complicated version that would allow you to do 4 at a time.
raw 367:*: {
%bans = $addtok(%bans,$3,32)
if ($numtok(%bans,32) == 4) { mode $2 -bbbb %bans | unset %bans }
halt
}
raw 368: { if (%bans) mode $2 - $+ $str(b,$numtok(%bans,32) %bans | unset %bans | halt }
%bans = $addtok(%bans,$3,32)
if ($numtok(%bans,32) == 4) { mode $2 -bbbb %bans | unset %bans }
halt
}
raw 368: { if (%bans) mode $2 - $+ $str(b,$numtok(%bans,32) %bans | unset %bans | halt }
So.. how does it work? As we receive each ban, we are adding the hostname to a variable called %bans. After we add the host, we see how many we have stored. If there are 4, we clear out 4 at once, then delete the variable. The next time around, we have an empty variable and try and add 4 more again.
In case you have an odd number of bans, we also have to check one last time as the ban list is finished. Since we only wipe bans every time we get 4, the above script would never unset them if there were only 3 bans. Once the server tells us that we have the ban list, we verify if %bans exists. if it does, we still have one last batch to get rid of. To avoid errors from the server, I used $str to repeat the b enough times to cover each unban. We could specify -bbbb, but the server might complain if you tell it your going to do 4 unbans and then only specify one hostname. The last thing we do is unset out %bans variable, and we're done!
001 : Welcome to the Internet Relay Network nickname
002 : Your host is server, running version ver
003 : This server was created datetime
004 server ver usermode chanmode
005 : map
005 protocols : are available on this server
007 : End of /MAP
008 num : Server notice mask (hex)
002 : Your host is server, running version ver
003 : This server was created datetime
004 server ver usermode chanmode
005 : map
005 protocols : are available on this server
007 : End of /MAP
008 num : Server notice mask (hex)
211 connection sendq sentmsg sentbyte recdmsg recdbyte pen
212 command uses bytes
213 C address * server port class
214 N address * server port class
215 I ipmask * hostmask port class
216 k address * username details
217 P port ?? ??
218 Y class ping freq maxconnect sendq
219 char :End of /STATS report
221 mode
222 B server * ?? ?? ??
223 E hostmask * username ?? ??
224 D ipmask * username ?? ??
241 L address * server ?? ??
242 : Server Up num days, time
243 o mask password user ?? class
244 H address * server ?? ??
247 G address timestamp :reason
248 U host * ?? ?? ??
249 : info
250 : Highest connection count: total (num clients)
251 : There are user users and invis invisible on serv servers
252 num perator(s) online
253 num :unknown connection(s)
254 num :channels formed
255 : I have user clients and serv servers
256 : Administrative info about server
257 : info
258 : info
259 : info
263 : Server load is temporarily too heavy. Please wait a while and try again.
265 : Current local users: curr Max: max
266 : Current global users: curr Max: max
272 nick : End of Silence List
280 address timestamp reason
281 : End of G-line List
290 : num ***** topic *****
291 : text
292 : ***** Go to #dalnethelp if you have any further questions *****
293 : text
294 : Your help-request has been forwarded to Help Operators
298 nick : Nickname conflict has been resolved
212 command uses bytes
213 C address * server port class
214 N address * server port class
215 I ipmask * hostmask port class
216 k address * username details
217 P port ?? ??
218 Y class ping freq maxconnect sendq
219 char :End of /STATS report
221 mode
222 B server * ?? ?? ??
223 E hostmask * username ?? ??
224 D ipmask * username ?? ??
241 L address * server ?? ??
242 : Server Up num days, time
243 o mask password user ?? class
244 H address * server ?? ??
247 G address timestamp :reason
248 U host * ?? ?? ??
249 : info
250 : Highest connection count: total (num clients)
251 : There are user users and invis invisible on serv servers
252 num perator(s) online
253 num :unknown connection(s)
254 num :channels formed
255 : I have user clients and serv servers
256 : Administrative info about server
257 : info
258 : info
259 : info
263 : Server load is temporarily too heavy. Please wait a while and try again.
265 : Current local users: curr Max: max
266 : Current global users: curr Max: max
272 nick : End of Silence List
280 address timestamp reason
281 : End of G-line List
290 : num ***** topic *****
291 : text
292 : ***** Go to #dalnethelp if you have any further questions *****
293 : text
294 : Your help-request has been forwarded to Help Operators
298 nick : Nickname conflict has been resolved
301 nick : away
302 : userhosts
303 : nicknames
305 : You are no longer marked as being away
306 : You have been marked as being away
307 : userips
307 nick : has identified for this nick
310 nick : looks very helpful
311 nick username address * : info
312 nick server : info
312 nick server : signoff
313 nick : is an IRC Operator
314 nick username address * : info
315 request : End of /WHO list.
317 nick seconds signon : info
318 request : End of /WHOIS list.
319 nick : channels
321 Channel : Users Name
322 channel users : topic
323 : End of /LIST
324 channel mode
328 channel :url
329 channel time
331 channel : No topic is set.
332 channel : topic
333 channel nickname time
341 nick channel
346 channel invite nick time
347 channel : End of Channel Invite List
348 channel exception nick time
349 channel : End of Channel Exception List
351 version.debug server :info
352 channel username address server nick flags :hops info
353 = channel : names
364 server hub : hops info
365 mask : End of /LINKS list.
366 channel : End of /NAMES list.
367 channel ban nick time
368 channel : End of Channel Ban List
369 request : End of WHOWAS
371 : info
372 : - info
374 : End of /INFO list.
375 : - server Message of the Day -
376 : End of /MOTD command.
377 : - info
378 : - info
381 : You are now an IRC Operator
382 file : Rehashing
391 server : time
302 : userhosts
303 : nicknames
305 : You are no longer marked as being away
306 : You have been marked as being away
307 : userips
307 nick : has identified for this nick
310 nick : looks very helpful
311 nick username address * : info
312 nick server : info
312 nick server : signoff
313 nick : is an IRC Operator
314 nick username address * : info
315 request : End of /WHO list.
317 nick seconds signon : info
318 request : End of /WHOIS list.
319 nick : channels
321 Channel : Users Name
322 channel users : topic
323 : End of /LIST
324 channel mode
328 channel :url
329 channel time
331 channel : No topic is set.
332 channel : topic
333 channel nickname time
341 nick channel
346 channel invite nick time
347 channel : End of Channel Invite List
348 channel exception nick time
349 channel : End of Channel Exception List
351 version.debug server :info
352 channel username address server nick flags :hops info
353 = channel : names
364 server hub : hops info
365 mask : End of /LINKS list.
366 channel : End of /NAMES list.
367 channel ban nick time
368 channel : End of Channel Ban List
369 request : End of WHOWAS
371 : info
372 : - info
374 : End of /INFO list.
375 : - server Message of the Day -
376 : End of /MOTD command.
377 : - info
378 : - info
381 : You are now an IRC Operator
382 file : Rehashing
391 server : time
401 nickname : No such nick
401 * : Target left UnderNet. Failed to deliver: message
402 server : No such server
403 channel : No such channel
404 channel : Cannot send to channel
405 channel : You have joined too many channels
406 nickname : There was no such nickname
407 target duplicate recipients. No message delivered
409 : No origin specified
411 : No recipient given (command)
412 : No text to send
413 mask : No toplevel domain specified
414 mask : Wildcard in toplevel Domain
416 command : Too many lines in the output, restrict your query
421 command : Unknown command
422 : MOTD File is missing
423 server : No administrative info available
431 : No nickname given
432 nickname : Erroneus Nickname
433 nickname : Nickname is already in use.
433 nickname : Nickname is registered to someone else.
436 nickname : Nickname collision KILL
437 channel : Cannot change nickname while banned on channel
438 nick : Nick change too fast. Please wait sec seconds.
439 target : Target change too fast. Please wait sec seconds.
441 nickname channel : They aren't on that channel
442 channel : You're not on that channel
443 nickname channel : is already on channel
445 : SUMMON has been disabled
446 : USERS has been disabled
451 command : Register first.
455 : Your username ident contained the invalid character(s) chars and has been changed to new. Please use only the characters 0-9 a-z A-Z _ - or . in your username. Your username is the part before the @ in your email address.
461 command : Not enough parameters
462 : You may not reregister
467 channel : Channel key already set
468 channel only servers can change that mode
471 channel : Cannot join channel (+l)
472 char : is unknown mode char to me
473 channel : Cannot join channel (+i)
474 channel : Cannot join channel (+b)
475 channel : Cannot join channel (+k)
477 channel : Channel doesn't support modes
477 channel : You need a registered nick to join that channel.
478 channel ban : Channel ban/ignore list is full
481 permission Denied- You're not an IRC operator
482 channel : You're not channel operator
483 : You cant kill a server!
484 nick channel : Cannot kill, kick or deop channel service
485 channel : Cannot join channel (reason)
491 : No O-lines for your host
401 * : Target left UnderNet. Failed to deliver: message
402 server : No such server
403 channel : No such channel
404 channel : Cannot send to channel
405 channel : You have joined too many channels
406 nickname : There was no such nickname
407 target duplicate recipients. No message delivered
409 : No origin specified
411 : No recipient given (command)
412 : No text to send
413 mask : No toplevel domain specified
414 mask : Wildcard in toplevel Domain
416 command : Too many lines in the output, restrict your query
421 command : Unknown command
422 : MOTD File is missing
423 server : No administrative info available
431 : No nickname given
432 nickname : Erroneus Nickname
433 nickname : Nickname is already in use.
433 nickname : Nickname is registered to someone else.
436 nickname : Nickname collision KILL
437 channel : Cannot change nickname while banned on channel
438 nick : Nick change too fast. Please wait sec seconds.
439 target : Target change too fast. Please wait sec seconds.
441 nickname channel : They aren't on that channel
442 channel : You're not on that channel
443 nickname channel : is already on channel
445 : SUMMON has been disabled
446 : USERS has been disabled
451 command : Register first.
455 : Your username ident contained the invalid character(s) chars and has been changed to new. Please use only the characters 0-9 a-z A-Z _ - or . in your username. Your username is the part before the @ in your email address.
461 command : Not enough parameters
462 : You may not reregister
467 channel : Channel key already set
468 channel only servers can change that mode
471 channel : Cannot join channel (+l)
472 char : is unknown mode char to me
473 channel : Cannot join channel (+i)
474 channel : Cannot join channel (+b)
475 channel : Cannot join channel (+k)
477 channel : Channel doesn't support modes
477 channel : You need a registered nick to join that channel.
478 channel ban : Channel ban/ignore list is full
481 permission Denied- You're not an IRC operator
482 channel : You're not channel operator
483 : You cant kill a server!
484 nick channel : Cannot kill, kick or deop channel service
485 channel : Cannot join channel (reason)
491 : No O-lines for your host
501 : Unknown MODE flag
502 : Cant change mode for other users
510 : You must resolve the nickname conflict before you can proceed
511 mask : Your silence list is full
512 : Authorization required to use Registered Nickname nick
512 address : No such gline
512 nick : Maximum size for WATCH-list is num entries
513 If you can't connect, type /QUOTE PONG code or /PONG code
502 : Cant change mode for other users
510 : You must resolve the nickname conflict before you can proceed
511 mask : Your silence list is full
512 : Authorization required to use Registered Nickname nick
512 address : No such gline
512 nick : Maximum size for WATCH-list is num entries
513 If you can't connect, type /QUOTE PONG code or /PONG code
600 nick userid host time :logged offline
601 nick userid host time :logged online
602 nick userid host time :stopped watching
603 : You have mine and are on other WATCH entries
604 nick userid host time :is online
605 nick userid host time :is offline
606 : nicklist
607 : End of WATCH query
601 nick userid host time :logged online
602 nick userid host time :stopped watching
603 : You have mine and are on other WATCH entries
604 nick userid host time :is online
605 nick userid host time :is offline
606 : nicklist
607 : End of WATCH query
000 nick PROP channel (ownerkey,hostkey,onjoin,onpart) (key or message)
800 1 0 GateKeeper,NTLM 512 *
801 channel (owner,host,voice,grant) entry (how long) (address of person you entered entry) tag
802 channel (owner,host,voice,grant) entry
803 channel Start of access entries
804 channel (owner,host,voice,grant) entry (how long) (address of person you entered entry) tag
805 channel End of access entries
820 channel (owner,host,voice,grant) Clear
908 channel access denied
914 channel duplicated access entry
923 channel Whispers disabled in channel
927 channel Already in channel
999 Unknown error code 75476594
800 1 0 GateKeeper,NTLM 512 *
801 channel (owner,host,voice,grant) entry (how long) (address of person you entered entry) tag
802 channel (owner,host,voice,grant) entry
803 channel Start of access entries
804 channel (owner,host,voice,grant) entry (how long) (address of person you entered entry) tag
805 channel End of access entries
820 channel (owner,host,voice,grant) Clear
908 channel access denied
914 channel duplicated access entry
923 channel Whispers disabled in channel
927 channel Already in channel
999 Unknown error code 75476594