| 1 |
pippijn |
1.4 |
/** |
| 2 |
|
|
* ircd_catserv.C: Meow! |
| 3 |
|
|
* |
| 4 |
|
|
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
| 5 |
|
|
* Rights to this code are as documented in COPYING. |
| 6 |
|
|
* |
| 7 |
|
|
* |
| 8 |
|
|
* Portions of this file were derived from sources bearing the following license: |
| 9 |
pippijn |
1.3 |
* Copyright © 2005 William Pitcock, et al. |
| 10 |
pippijn |
1.2 |
* The rights to this code are as documented under doc/pod/license.pod. |
| 11 |
pippijn |
1.1 |
* |
| 12 |
pippijn |
1.5 |
* $Id: ircd_catserv.C,v 1.4 2007-09-16 18:54:43 pippijn Exp $ |
| 13 |
pippijn |
1.1 |
*/ |
| 14 |
|
|
|
| 15 |
|
|
#include "atheme.h" |
| 16 |
pippijn |
1.3 |
#include <ermyth/module.h> |
| 17 |
pippijn |
1.1 |
|
| 18 |
pippijn |
1.5 |
static char const rcsid[] = "$Id: ircd_catserv.C,v 1.4 2007-09-16 18:54:43 pippijn Exp $"; |
| 19 |
pippijn |
1.3 |
|
| 20 |
pippijn |
1.5 |
REGISTER_MODULE ("contrib/ircd_catserv", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
| 21 |
pippijn |
1.1 |
|
| 22 |
|
|
service_t *catserv; |
| 23 |
|
|
cmdvec catserv_cmdtree; |
| 24 |
|
|
|
| 25 |
|
|
static void catserv_cmd_meow (sourceinfo_t *si, int parc, char *parv[]); |
| 26 |
|
|
static void catserv_cmd_help (sourceinfo_t *si, int parc, char *parv[]); |
| 27 |
|
|
static void catserv_handler (sourceinfo_t *si, int parc, char **parv); |
| 28 |
|
|
|
| 29 |
pippijn |
1.3 |
command_t const catserv_meow = { "MEOW", "Makes the cute little kitty-cat meow!", AC_NONE, 0, catserv_cmd_meow }; |
| 30 |
|
|
command_t const catserv_help = { "HELP", "Displays contextual help information.", AC_NONE, 1, catserv_cmd_help }; |
| 31 |
pippijn |
1.1 |
|
| 32 |
pippijn |
1.3 |
bool |
| 33 |
|
|
_modinit (module *m) |
| 34 |
pippijn |
1.1 |
{ |
| 35 |
|
|
catserv = add_service ("CatServ", "meow", "meowth.nu", "Kitty cat!", catserv_handler, catserv_cmdtree); |
| 36 |
|
|
|
| 37 |
pippijn |
1.3 |
catserv_cmdtree << catserv_meow; |
| 38 |
|
|
catserv_cmdtree << catserv_help; |
| 39 |
|
|
|
| 40 |
|
|
return true; |
| 41 |
pippijn |
1.1 |
} |
| 42 |
|
|
|
| 43 |
|
|
void |
| 44 |
|
|
_moddeinit () |
| 45 |
|
|
{ |
| 46 |
pippijn |
1.3 |
catserv_cmdtree >> catserv_help; |
| 47 |
|
|
catserv_cmdtree >> catserv_meow; |
| 48 |
pippijn |
1.1 |
|
| 49 |
|
|
del_service (catserv); |
| 50 |
|
|
} |
| 51 |
|
|
|
| 52 |
|
|
static void |
| 53 |
|
|
catserv_cmd_meow (sourceinfo_t *si, int parc, char *parv[]) |
| 54 |
|
|
{ |
| 55 |
|
|
command_success_nodata (si, "Meow!"); |
| 56 |
|
|
} |
| 57 |
|
|
|
| 58 |
|
|
static void |
| 59 |
|
|
catserv_cmd_help (sourceinfo_t *si, int parc, char *parv[]) |
| 60 |
|
|
{ |
| 61 |
pippijn |
1.3 |
command_help (si, catserv_cmdtree); |
| 62 |
pippijn |
1.1 |
} |
| 63 |
|
|
|
| 64 |
|
|
static void |
| 65 |
|
|
catserv_handler (sourceinfo_t *si, int parc, char *parv[]) |
| 66 |
|
|
{ |
| 67 |
|
|
char orig[BUFSIZE]; |
| 68 |
|
|
char *cmd; |
| 69 |
|
|
char *text; |
| 70 |
|
|
|
| 71 |
|
|
/* this should never happen */ |
| 72 |
|
|
if (parv[0][0] == '&') |
| 73 |
|
|
{ |
| 74 |
|
|
slog (LG_ERROR, "services(): got parv with local channel: %s", parv[0]); |
| 75 |
|
|
return; |
| 76 |
|
|
} |
| 77 |
|
|
|
| 78 |
|
|
/* make a copy of the original for debugging */ |
| 79 |
|
|
strlcpy (orig, parv[parc - 1], BUFSIZE); |
| 80 |
|
|
|
| 81 |
|
|
/* lets go through this to get the command */ |
| 82 |
|
|
cmd = strtok (parv[parc - 1], " "); |
| 83 |
|
|
text = strtok (NULL, ""); |
| 84 |
|
|
|
| 85 |
|
|
if (!cmd) |
| 86 |
|
|
return; |
| 87 |
|
|
if (*cmd == '\001') |
| 88 |
|
|
{ |
| 89 |
|
|
handle_ctcp_common (si, cmd, text); |
| 90 |
|
|
return; |
| 91 |
|
|
} |
| 92 |
|
|
|
| 93 |
|
|
/* take the command through the hash table */ |
| 94 |
pippijn |
1.3 |
command_exec_split (catserv, si, cmd, text, catserv_cmdtree); |
| 95 |
pippijn |
1.1 |
} |