xchat isn't a KDE application so you may not get much help here. Try the xchat website (
http://www.xchat.org/). I notice they have a few docs in their documentation section (
http://xchat.org/docs/) regarding scripting that may be the place to start.
BTW, you should be using Konversation or Kopete.