Trapping incoming message for custom action?

I want to build a plugin that will trap a certain custom message and perform specific action. for example, I want to send a special link, and the plugins detect this and popup the browser window automatically. This process shoud be done even before the chat windows is opened. The only way I see is to insert special hook in handleIncomingPacket from spark code base.

Is there a better way with just plugin code, without touching the base code?

Thanks a lot for any info.