ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/invite.C
Revision: 1.4
Committed: Sun Jul 22 18:38:43 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +3 -3 lines
Log Message:
-fixed help
- temporarily work around corruption in jsonrpc

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2005 William Pitcock, et al.
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * This file contains code for the CService INVITE functions.
6     *
7 pippijn 1.4 * $Id: invite.C,v 1.3 2007-07-21 13:23:18 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11     #include <account/mychan.h>
12     #include <account/chanacs.h>
13    
14 pippijn 1.4 static char const rcsid[] = "$Id: invite.C,v 1.3 2007-07-21 13:23:18 pippijn Exp $";
15 pippijn 1.1
16     struct cs_invite_listeners : callback::has_listeners
17     {
18     };
19    
20     cs_invite_listeners listeners;
21    
22     DECLARE_MODULE_V1 ("chanserv/invite", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
23    
24     static void cs_cmd_invite (sourceinfo_t *si, int parc, char *parv[]);
25    
26     command_t cs_invite = { "INVITE", N_("Invites you to a channel."),
27     AC_NONE, 1, cs_cmd_invite
28     };
29    
30     cmdvec *cs_cmdtree;
31     helpvec *cs_helptree;
32    
33     void
34     _modinit (module_t *m)
35     {
36     MODULE_USE_SYMBOL_T (cs_cmdtree, cmdvec, "chanserv/main", "cs_cmdtree");
37     MODULE_USE_SYMBOL_T (cs_helptree, helpvec, "chanserv/main", "cs_helptree");
38    
39     cs_cmdtree << cs_invite;
40 pippijn 1.4 help_addentry (cs_helptree, "INVITE", "help/chanserv/invite", NULL);
41 pippijn 1.1 }
42    
43     void
44     _moddeinit ()
45     {
46     cs_cmdtree >> cs_invite;
47     help_delentry (cs_helptree, "INVITE");
48     }
49    
50     static void
51     cs_cmd_invite (sourceinfo_t *si, int parc, char *parv[])
52     {
53     char *chan = parv[0];
54     mychan_t *mc;
55    
56     if (si->su == NULL)
57     {
58     command_fail (si, fault_noprivs, _("\2%s\2 can only be executed via IRC."), "INVITE");
59     return;
60     }
61    
62     if (!chan)
63     {
64     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "INVITE");
65     command_fail (si, fault_needmoreparams, _("Syntax: INVITE <#channel>"));
66     return;
67     }
68    
69     mc = mychan_find (chan);
70     if (!mc)
71     {
72     command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), chan);
73     return;
74     }
75    
76     if (mc->find_metadata ("private:close:closer"))
77     {
78     command_fail (si, fault_noprivs, _("\2%s\2 is closed."), chan);
79     return;
80     }
81    
82     if (!chanacs_source_has_flag (mc, si, CA_INVITE))
83     {
84     command_fail (si, fault_noprivs, _("You are not authorized to perform this operation."));
85     return;
86     }
87    
88     if (chanuser_find (mc->chan, si->su))
89     {
90     command_fail (si, fault_noprivs, _("You're already on \2%s\2."), mc->name);
91     return;
92     }
93    
94     if (!mc->chan)
95     {
96     command_fail (si, fault_nosuch_target, _("\2%s\2 is currently empty."), mc->name);
97     return;
98     }
99    
100     invite_sts (si->service->me, si->su, mc->chan);
101     logcommand (si, CMDLOG_SET, "%s INVITE", mc->name);
102     command_success_nodata (si, _("You have been invited to \2%s\2."), mc->name);
103     }
104    
105     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
106     * vim:ts=8
107     * vim:sw=8
108     * vim:noexpandtab
109     */