ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/clear.C
Revision: 1.7
Committed: Sun Sep 16 18:54:42 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +10 -5 lines
Log Message:
#defines to enum

File Contents

# User Rev Content
1 pippijn 1.7 /**
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 pippijn 1.5 * Copyright © 2005 William Pitcock, et al.
10 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
11 pippijn 1.1 *
12 pippijn 1.7 * $Id: clear.C,v 1.6 2007-08-30 19:56:20 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.5 #include <ermyth/module.h>
17 pippijn 1.1
18 pippijn 1.7 static char const rcsid[] = "$Id: clear.C,v 1.6 2007-08-30 19:56:20 pippijn Exp $";
19 pippijn 1.1
20 pippijn 1.5 REGISTER_MODULE ("chanserv/clear", false, "The Ermyth Team <http://ermyth.schmorp.de>");
21 pippijn 1.1
22     static void cs_cmd_clear (sourceinfo_t *si, int parc, char *parv[]);
23     static void cs_help_clear (sourceinfo_t *si);
24    
25 pippijn 1.5 command_t const cs_clear = { "CLEAR", N_("Channel removal toolkit."), AC_NONE, 3, cs_cmd_clear };
26 pippijn 1.1
27 pippijn 1.5 E cmdvec cs_cmdtree;
28     E helpvec cs_helptree;
29 pippijn 1.1 cmdvec cs_clear_cmds;
30    
31 pippijn 1.5 bool
32     _modinit (module *m)
33 pippijn 1.1 {
34     cs_cmdtree << cs_clear;
35     help_addentry (cs_helptree, "CLEAR", NULL, cs_help_clear);
36 pippijn 1.5
37     return true;
38 pippijn 1.1 }
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 pippijn 1.5 command_help (si, cs_clear_cmds);
56 pippijn 1.1 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 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "CLEAR");
70     command_fail (si, fault::needmoreparams, _("Syntax: CLEAR <#channel> <command> [parameters]"));
71 pippijn 1.1 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 pippijn 1.6 command_fail (si, fault::badparams, STR_INVALID_PARAMS, "CLEAR");
81     command_fail (si, fault::badparams, _("Syntax: CLEAR <#channel> <command> [parameters]"));
82 pippijn 1.1 return;
83     }
84    
85     c = cs_clear_cmds.find (cmd);
86     if (c == NULL)
87     {
88 pippijn 1.6 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 pippijn 1.1 return;
90     }
91    
92     parv[1] = chan;
93     c->exec (si->service, si, parc - 1, parv + 1);
94     }