ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/chanserv/clear_bans.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_bans.C: This file contains code for the ChanServ CLEAR BANS 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_bans.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $
13 */
14
15 #include "atheme.h"
16 #include <ermyth/module.h>
17 #include <account/mychan.h>
18 #include <account/chanacs.h>
19
20 static char const rcsid[] = "$Id: clear_bans.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $";
21
22 REGISTER_MODULE ("chanserv/clear_bans", false, "The Ermyth Team <http://ermyth.xinutec.org>");
23
24 static void cs_cmd_clear_bans (sourceinfo_t *si, int parc, char *parv[]);
25
26 command_t const cs_clear_bans = { "BANS", N_("Clears bans or other lists of a channel."), AC_NONE, 2, cs_cmd_clear_bans };
27
28 E cmdvec cs_clear_cmds;
29 E helpvec cs_helptree;
30
31 bool
32 _modinit (module *m)
33 {
34 cs_clear_cmds << cs_clear_bans;
35 help_addentry (cs_helptree, "CLEAR BANS", "help/chanserv/clear_bans", NULL);
36
37 return true;
38 }
39
40 void
41 _moddeinit ()
42 {
43 cs_clear_cmds >> cs_clear_bans;
44
45 help_delentry (cs_helptree, "CLEAR BANS");
46 }
47
48 static void
49 cs_cmd_clear_bans (sourceinfo_t *si, int parc, char *parv[])
50 {
51 channel_t *c;
52 mychan_t *mc = mychan_t::find (parv[0]);
53 chanban_t *cb;
54 node_t *n, *tn;
55 char const *item = parv[1], *p;
56 int hits;
57
58 if (item == NULL)
59 item = "b";
60 if (*item == '+' || *item == '-')
61 item++;
62 if (!strcmp (item, "*"))
63 item = ircd->ban_like_modes;
64 for (p = item; *p != '\0'; p++)
65 {
66 if (!strchr (ircd->ban_like_modes, *p))
67 {
68 command_fail (si, fault::badparams, _("Invalid mode; valid ones are %s."), ircd->ban_like_modes);
69 return;
70 }
71 }
72 if (*item == '\0')
73 {
74 command_fail (si, fault::badparams, _("Invalid mode; valid ones are %s."), ircd->ban_like_modes);
75 return;
76 }
77
78 if (!mc)
79 {
80 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), parv[0]);
81 return;
82 }
83
84 if (!(c = channel_find (parv[0])))
85 {
86 command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), parv[0]);
87 return;
88 }
89
90 if (!chanacs_source_has_flag (mc, si, CA_RECOVER))
91 {
92 command_fail (si, fault::noprivs, _("You are not authorized to perform this operation."));
93 return;
94 }
95
96 if (mc->find_metadata ("private:close:closer"))
97 {
98 command_fail (si, fault::noprivs, _("\2%s\2 is closed."), parv[0]);
99 return;
100 }
101
102 hits = 0;
103 LIST_FOREACH_SAFE (n, tn, c->bans.head)
104 {
105 cb = static_cast<chanban_t *> (n->data);
106 if (!strchr (item, cb->type))
107 continue;
108 modestack_mode_param (chansvs.nick, c, MTYPE_DEL, cb->type, cb->mask);
109 chanban_delete (cb);
110 hits++;
111 }
112
113 logcommand (si, CMDLOG_DO, "%s CLEAR BANS %s", mc->name, item);
114
115 command_success_nodata (si, _("Cleared %s modes on \2%s\2 (%d removed)."), item, parv[0], hits);
116 }