ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/drop.C
Revision: 1.8
Committed: Sat Sep 22 14:27:27 2007 UTC (19 years 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

# User Rev Content
1 pippijn 1.7 /**
2     * drop.C: This file contains code for the ChanServ DROP function.
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.8 * $Id: drop.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.5 #include <ermyth/module.h>
17 pippijn 1.1 #include <account/myuser.h>
18     #include <account/mychan.h>
19    
20 pippijn 1.8 static char const rcsid[] = "$Id: drop.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $";
21 pippijn 1.1
22 pippijn 1.8 REGISTER_MODULE ("chanserv/drop", false, "The Ermyth Team <http://ermyth.xinutec.org>");
23 pippijn 1.1
24     static void cs_cmd_drop (sourceinfo_t *si, int parc, char *parv[]);
25    
26 pippijn 1.5 command_t const cs_drop = { "DROP", N_("Drops a channel registration."), AC_NONE, 1, cs_cmd_drop };
27 pippijn 1.1
28 pippijn 1.5 E cmdvec cs_cmdtree;
29     E helpvec cs_helptree;
30 pippijn 1.1
31 pippijn 1.5 bool
32     _modinit (module *m)
33 pippijn 1.1 {
34     cs_cmdtree << cs_drop;
35 pippijn 1.4 help_addentry (cs_helptree, "DROP", "help/chanserv/drop", NULL);
36 pippijn 1.5
37     return true;
38 pippijn 1.1 }
39    
40     void
41     _moddeinit ()
42     {
43     cs_cmdtree >> cs_drop;
44     help_delentry (cs_helptree, "DROP");
45     }
46    
47     static void
48     cs_cmd_drop (sourceinfo_t *si, int parc, char *parv[])
49     {
50     mychan_t *mc;
51     char *name = parv[0];
52    
53     if (!name)
54     {
55 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP");
56     command_fail (si, fault::needmoreparams, _("Syntax: DROP <#channel>"));
57 pippijn 1.1 return;
58     }
59    
60     if (*name != '#')
61     {
62 pippijn 1.6 command_fail (si, fault::badparams, STR_INVALID_PARAMS, "DROP");
63     command_fail (si, fault::badparams, _("Syntax: DROP <#channel>"));
64 pippijn 1.1 return;
65     }
66    
67 pippijn 1.6 if (!(mc = mychan_t::find (name)))
68 pippijn 1.1 {
69 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), name);
70 pippijn 1.1 return;
71     }
72    
73     if (si->c != NULL)
74     {
75 pippijn 1.6 command_fail (si, fault::noprivs, _("For security reasons, you may not drop a channel registration with a fantasy command."));
76 pippijn 1.1 return;
77     }
78    
79 pippijn 1.5 if (!si->smu->is_founder (mc) && !has_priv (si, PRIV_CHAN_ADMIN))
80 pippijn 1.1 {
81 pippijn 1.6 command_fail (si, fault::noprivs, _("You are not authorized to perform this operation."));
82 pippijn 1.1 return;
83     }
84    
85     if (mc->find_metadata ("private:close:closer") && !has_priv (si, PRIV_CHAN_ADMIN))
86     {
87     logcommand (si, CMDLOG_REGISTER, "%s failed DROP (closed)", mc->name);
88 pippijn 1.6 command_fail (si, fault::noprivs, _("The channel \2%s\2 is closed; it cannot be dropped."), mc->name);
89 pippijn 1.1 return;
90     }
91    
92     if (mc->flags & MC_HOLD)
93     {
94 pippijn 1.6 command_fail (si, fault::noprivs, _("The channel \2%s\2 is held; it cannot be dropped."), mc->name);
95 pippijn 1.1 return;
96     }
97    
98 pippijn 1.5 if (!si->smu->is_founder (mc))
99 pippijn 1.1 {
100     logcommand (si, CMDLOG_ADMIN | LG_REGISTER, "%s DROP", mc->name);
101     wallops ("%s dropped the channel \2%s\2", get_oper_name (si), name);
102     }
103     else
104     logcommand (si, CMDLOG_REGISTER, "%s DROP", mc->name);
105    
106     snoop ("DROP: \2%s\2 by \2%s\2 as \2%s\2", mc->name, get_oper_name (si), si->smu->name);
107    
108 pippijn 1.5 mc->callback.drop (mc);
109 pippijn 1.1 if ((config_options.chan && irccasecmp (mc->name, config_options.chan)) || !config_options.chan)
110     part (mc->name, chansvs.nick);
111     mc->refcnt_dec ();
112     command_success_nodata (si, _("The channel \2%s\2 has been dropped."), name);
113     return;
114     }