ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/chanserv/clear.C
Revision: 1.8
Committed: Sat Sep 22 14:27:27 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +3 -3 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# Content
1 /**
2 * clear.C: This file contains code for the ChanServ CLEAR functions.
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 * Copyright © 2005 William Pitcock, et al.
10 * Rights to this code are as documented in doc/pod/license.pod.
11 *
12 * $Id: clear.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $
13 */
14
15 #include "atheme.h"
16 #include <ermyth/module.h>
17
18 static char const rcsid[] = "$Id: clear.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $";
19
20 REGISTER_MODULE ("chanserv/clear", false, "The Ermyth Team <http://ermyth.xinutec.org>");
21
22 static void cs_cmd_clear (sourceinfo_t *si, int parc, char *parv[]);
23 static void cs_help_clear (sourceinfo_t *si);
24
25 command_t const cs_clear = { "CLEAR", N_("Channel removal toolkit."), AC_NONE, 3, cs_cmd_clear };
26
27 E cmdvec cs_cmdtree;
28 E helpvec cs_helptree;
29 cmdvec cs_clear_cmds;
30
31 bool
32 _modinit (module *m)
33 {
34 cs_cmdtree << cs_clear;
35 help_addentry (cs_helptree, "CLEAR", NULL, cs_help_clear);
36
37 return true;
38 }
39
40 void
41 _moddeinit ()
42 {
43 cs_cmdtree >> cs_clear;
44
45 help_delentry (cs_helptree, "CLEAR");
46 }
47
48 static void
49 cs_help_clear (sourceinfo_t *si)
50 {
51 command_success_nodata (si, _("Help for \2CLEAR\2:"));
52 command_success_nodata (si, " ");
53 command_success_nodata (si, _("CLEAR allows you to clear various aspects of a channel."));
54 command_success_nodata (si, " ");
55 command_help (si, cs_clear_cmds);
56 command_success_nodata (si, " ");
57 command_success_nodata (si, _("For more information, use \2/msg %s HELP CLEAR \37command\37\2."), si->service->disp);
58 }
59
60 static void
61 cs_cmd_clear (sourceinfo_t *si, int parc, char *parv[])
62 {
63 char *chan;
64 char *cmd;
65 command_t const *c;
66
67 if (parc < 2)
68 {
69 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "CLEAR");
70 command_fail (si, fault::needmoreparams, _("Syntax: CLEAR <#channel> <command> [parameters]"));
71 return;
72 }
73
74 if (parv[0][0] == '#')
75 chan = parv[0], cmd = parv[1];
76 else if (parv[1][0] == '#')
77 cmd = parv[0], chan = parv[1];
78 else
79 {
80 command_fail (si, fault::badparams, STR_INVALID_PARAMS, "CLEAR");
81 command_fail (si, fault::badparams, _("Syntax: CLEAR <#channel> <command> [parameters]"));
82 return;
83 }
84
85 c = cs_clear_cmds.find (cmd);
86 if (c == NULL)
87 {
88 command_fail (si, fault::badparams, _("Invalid command. Use \2/%s%s help\2 for a command listing."), (ircd->uses_rcommand == false) ? "msg " : "", si->service->disp);
89 return;
90 }
91
92 parv[1] = chan;
93 c->exec (si->service, si, parc - 1, parv + 1);
94 }