ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/chanserv/invite.C
Revision: 1.7
Committed: Sun Sep 16 18:54:43 2007 UTC (19 years 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     * invite.C: This file contains code for the ChanServ INVITE 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: invite.C,v 1.6 2007-08-30 19:56:22 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/mychan.h>
18     #include <account/chanacs.h>
19    
20 pippijn 1.7 static char const rcsid[] = "$Id: invite.C,v 1.6 2007-08-30 19:56:22 pippijn Exp $";
21 pippijn 1.1
22 pippijn 1.5 REGISTER_MODULE ("chanserv/invite", false, "The Ermyth Team <http://ermyth.schmorp.de>");
23 pippijn 1.1
24     static void cs_cmd_invite (sourceinfo_t *si, int parc, char *parv[]);
25    
26 pippijn 1.5 command_t const cs_invite = { "INVITE", N_("Invites you to a channel."), AC_NONE, 1, cs_cmd_invite };
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_invite;
35 pippijn 1.4 help_addentry (cs_helptree, "INVITE", "help/chanserv/invite", NULL);
36 pippijn 1.5
37     return true;
38 pippijn 1.1 }
39    
40     void
41     _moddeinit ()
42     {
43     cs_cmdtree >> cs_invite;
44     help_delentry (cs_helptree, "INVITE");
45     }
46    
47     static void
48     cs_cmd_invite (sourceinfo_t *si, int parc, char *parv[])
49     {
50     char *chan = parv[0];
51     mychan_t *mc;
52    
53     if (si->su == NULL)
54     {
55 pippijn 1.6 command_fail (si, fault::noprivs, _("\2%s\2 can only be executed via IRC."), "INVITE");
56 pippijn 1.1 return;
57     }
58    
59     if (!chan)
60     {
61 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "INVITE");
62     command_fail (si, fault::needmoreparams, _("Syntax: INVITE <#channel>"));
63 pippijn 1.1 return;
64     }
65    
66 pippijn 1.6 mc = mychan_t::find (chan);
67 pippijn 1.1 if (!mc)
68     {
69 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), chan);
70 pippijn 1.1 return;
71     }
72    
73     if (mc->find_metadata ("private:close:closer"))
74     {
75 pippijn 1.6 command_fail (si, fault::noprivs, _("\2%s\2 is closed."), chan);
76 pippijn 1.1 return;
77     }
78    
79     if (!chanacs_source_has_flag (mc, si, CA_INVITE))
80     {
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 (chanuser_find (mc->chan, si->su))
86     {
87 pippijn 1.6 command_fail (si, fault::noprivs, _("You're already on \2%s\2."), mc->name);
88 pippijn 1.1 return;
89     }
90    
91     if (!mc->chan)
92     {
93 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), mc->name);
94 pippijn 1.1 return;
95     }
96    
97 pippijn 1.5 phandler->invite_sts (si->service->me, si->su, mc->chan);
98 pippijn 1.1 logcommand (si, CMDLOG_SET, "%s INVITE", mc->name);
99     command_success_nodata (si, _("You have been invited to \2%s\2."), mc->name);
100     }