I find it very dodgy (read: hard to believe) that your ISP will change your IP while you are connected...
Anyways, yes this can be made into a plugin. But both you and the contact need the plugin to be installed.
In other words, you can't use it to get the IP of other contacts...
Otherwise, EvilSeph's method works also and is even more secure then if you put this into a plugin (cause anybody can use the plugin's command to get your IP).