ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/chanserv/invite.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 * 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 * Copyright © 2005 William Pitcock, et al.
10 * Rights to this code are as documented in doc/pod/license.pod.
11 *
12 * $Id: invite.C,v 1.7 2007-09-16 18:54:43 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: invite.C,v 1.7 2007-09-16 18:54:43 pippijn Exp $";
21
22 REGISTER_MODULE ("chanserv/invite", false, "The Ermyth Team <http://ermyth.xinutec.org>");
23
24 static void cs_cmd_invite (sourceinfo_t *si, int parc, char *parv[]);
25
26 command_t const cs_invite = { "INVITE", N_("Invites you to a channel."), AC_NONE, 1, cs_cmd_invite };
27
28 E cmdvec cs_cmdtree;
29 E helpvec cs_helptree;
30
31 bool
32 _modinit (module *m)
33 {
34 cs_cmdtree << cs_invite;
35 help_addentry (cs_helptree, "INVITE", "help/chanserv/invite", NULL);
36
37 return true;
38 }
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 command_fail (si, fault::noprivs, _("\2%s\2 can only be executed via IRC."), "INVITE");
56 return;
57 }
58
59 if (!chan)
60 {
61 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "INVITE");
62 command_fail (si, fault::needmoreparams, _("Syntax: INVITE <#channel>"));
63 return;
64 }
65
66 mc = mychan_t::find (chan);
67 if (!mc)
68 {
69 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), chan);
70 return;
71 }
72
73 if (mc->find_metadata ("private:close:closer"))
74 {
75 command_fail (si, fault::noprivs, _("\2%s\2 is closed."), chan);
76 return;
77 }
78
79 if (!chanacs_source_has_flag (mc, si, CA_INVITE))
80 {
81 command_fail (si, fault::noprivs, _("You are not authorized to perform this operation."));
82 return;
83 }
84
85 if (chanuser_find (mc->chan, si->su))
86 {
87 command_fail (si, fault::noprivs, _("You're already on \2%s\2."), mc->name);
88 return;
89 }
90
91 if (!mc->chan)
92 {
93 command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), mc->name);
94 return;
95 }
96
97 phandler->invite_sts (si->service->me, si->su, mc->chan);
98 logcommand (si, CMDLOG_SET, "%s INVITE", mc->name);
99 command_success_nodata (si, _("You have been invited to \2%s\2."), mc->name);
100 }