/1 On xchat_plugin_init and friends.
xchat_plugin_init is called by X-Chat the moment it loads your plugin, obviously. As shown in the example, the X-Chat plugin context must be initialized in this function (declared as static xchat_plugin *ph; in the docs). This is necessary since all other function calls you could possibly use require this value as first parameter. There isn't much else to do here except for hooking various events, with xchat_hook_command etc. After this method returns, your plugin should be ready to to whatever you want it to do.
xchat_plugin_deinit is called when either you or X-Chat unload your plugin, i.e. by using the plugin manager or shutting down X-Chat. Implementing this method isn't strictly necessary unless you allocated global memory and/or system resources in your xchat_plugin_init method. In that case, those resources must be freed here unless you want to run into memory/resource leaks.
I'm not really sure what actually calls xchat_plugin_get_info (the plugin manager, maybe?), but I vaguely remember that not implementing this function didn't do any major damage last time I did a C plugin. You might just want to use the code provided in the sample and forget about the method.
And that's all for pre-defined methods already. Everything else is basically xchat_hook_*.
The value you have to pass as const char *name
has to be one of the values available in the "Advanced > Text Events" menu of X-Chat. If you want to respond to channel text, you'd have to pass "Channel Message", for example. Your own text isn't included in this hook, you'd have to hook "Your Message" as well. Anyway, with this you can hook any event that causes X-Chat to print something along the way. You'll get the idea when scrolling through the Text Events window.
Now, assuming you'll hook "Channel Message". Every message will be first passed through the callback function you specified (the order in which an event passes through various hooks is specified with the priority argument of xchat_hook_print). A specific number of arguments is always available through char* word
. The elements of this array correspond to the values seen in the "Text Events" window (e.g. for "Channel message", you'll see that index 1 is nickname, index 2 is text, and index 3 is user mode. This corresponds to word, word, and word. word is reserved for X-Chat and musn't be modified.).
Since you probably won't be interested in every single message, you'll have to manually check for the trigger here, that is, word. strcmp(word, "!trigger"), or whatever floats your boat. Various other information is available with xchat_get_info(), such the channel, network, etc.
The simplest way to get a feel for the hook_print interface is to set up a simple test callback that just prints every element of word.
You might also want to read this
thread, there's some info on this subject as well.