The best ways to do this (afaik) would be to either:
1) Only do this with people you know. Set up the country manually for each user in a hash table or a file and read in the data for that user. If there is a country listed for the user, then you display that with the nick. That's pretty easy, but only works for nicks you manually enter a country for.
2) Obtain the information from the $address of the user. You can get *some* automatically from that. Obviously, .uk is going to be a UK ISP. However, some countries sell their suffixes, so that's not even 100% certain. Many hosts don't list a country, so for those, just using $address won't do much for you. The best method in that case would be to socket a site like
http://www.networksolutions.com/whois/index.jsp ... you can then use the socket connection to search for the host information and find out where it is located. Keep in mind that this will only show you where the host is located... not where the user is located. In many cases, this will be the same, but not in all cases.
As a final note, if you go the route of socketing that site, it can cause you to lag considerably if a lot of text is being seen all at once. I would recommend having it only search each nick's host once (perhaps on join) and store the information so that you don't have to figure out the country everytime the user speaks. This should be relatively easy to do and would be better in the scripting forum if done.