Advertisement
NovaYoshi

Sample plugin to add NovaBot commands

Jun 21st, 2011
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.50 KB | None | 0 0
  1. /*
  2.   External commands test
  3. */
  4. #include "xchat-plugin.h"
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8.  
  9. #define PNAME "Command test"
  10. #define PDESC "8====D~~~~~~"
  11. #define PVERSION "0.01"
  12.  
  13. static xchat_plugin *ph;   /* plugin handle */
  14. // 1         2        3       4    (search for -A and begin from there)
  15. // NB_ExtCmd replycmd command nick -A arguments
  16. static int nb_extcmdtest_cb(char *word[], char *word_eol[], void *userdata) {
  17.    if(NULL != word[3] && !strcasecmp(word[3], "extcmdtest") && NULL != word[2] && NULL != word[4]) {
  18.      xchat_commandf(ph, "%s used by %s", word[2], word[4]);
  19.      return XCHAT_EAT_ALL; // command matches so don't let NovaBot complain about it
  20.    }
  21.    return XCHAT_EAT_NONE; // let other plugins see it
  22. }
  23.  
  24. void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved) {
  25.    *name = PNAME;
  26.    *desc = PDESC;
  27.    *version = PVERSION;
  28. }
  29.  
  30. int xchat_plugin_deinit() {
  31.    return 1;
  32. }
  33.  
  34. int xchat_plugin_init(xchat_plugin *plugin_handle,
  35.                       char **plugin_name,
  36.                       char **plugin_desc,
  37.                       char **plugin_version,
  38.                       char *arg) {
  39.    /* we need to save this for use with any xchat_* functions */
  40.    ph = plugin_handle;
  41.  
  42.    /* tell xchat our info */
  43.    *plugin_name = PNAME;   *plugin_desc = PDESC;   *plugin_version = PVERSION;
  44.  
  45.    xchat_hook_command(ph, "NB_ExtCmd", XCHAT_PRI_NORM, nb_extcmdtest_cb, NULL, 0);
  46.    return 1;       /* return 1 for success */
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement