A little while back I was trying to make a small IRC bot but I eventually lost my interest in it. While writing the bot I had to write a regex to match the raw IRC message pattern. A friend (thanks Jobe) on IRC came up with the following regex:

^(?:[:@]([^\\s]+) )?([^\\s]+)(?: ((?:[^:\\s][^\\s]* ?)*))?(?: ?:(.*))?$

It will match 4 groups (source, command, target and the parameters). A small example in JAVA:

Pattern pattern = Pattern.compile("^(?:[:@]([^\\s]+) )?([^\\s]+)(?: ((?:[^:\\s][^\\s]* ?)*))?(?: ?:(.*))?$");
Matcher matcher = pattern.matcher(line.subSequence(0, line.length()));
 
if (matcher.matches()) {
	//i.e irc.mibbit.net
	source = matcher.group(1);
	//i.e 433/NOTICE
	cmd = matcher.group(2);
	//i.e RoomBot/#mibbit
	target = matcher.group(3);
	//i.e I have 3093 clients and 1 servers
	param = matcher.group(4);
}

Would you have done differently?

 

I’m happy to announce my first Google Chrome extension: IRC to Mibbit.
This plugin makes Mibbit the default IRC handler by replacing the IRC uri’s (irc:// and ircs://) to http(s)://www.mibbit.com/#channel@irc.foo.bar
Since this is my first Google Chrome extension it might be possible that it contains bugs, of course I test it myself but couldn’t find any. So please if you have comments or if you did find a bug report it in the comments under this blogpost.

You can download the extension at the Google Chrome Extension Gallery

 

As some of you might know I am a IRC Operator at irc.mibbit.net. Mibbit’s IRC server is the default server for the famous online IRC client Mibbit.
The lack of a good Mibbit plugin for WordPress made me decide to write my own and I’m proud to announce the release of this new plugin!
The plugin can be found at the WordPress Plugin Directory
If you find a bug or if you have any suggestions you can leave a comment on this blog post.

© 2011 Joshua Lückers Suffusion theme by Sayontan Sinha