ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/operserv/mode.C
Revision: 1.9
Committed: Sat Sep 22 14:27:28 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +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.8 /**
2     * mode.C: This file contains functionality which implements the OperServ MODE command.
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.6 * Copyright © 2005-2006 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.9 * $Id: mode.C,v 1.8 2007-09-16 18:54:44 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.6 #include <ermyth/module.h>
17 pippijn 1.1
18 pippijn 1.9 static char const rcsid[] = "$Id: mode.C,v 1.8 2007-09-16 18:54:44 pippijn Exp $";
19 pippijn 1.1
20 pippijn 1.9 REGISTER_MODULE ("operserv/mode", false, "The Ermyth Team <http://ermyth.xinutec.org>");
21 pippijn 1.1
22     static void os_cmd_mode (sourceinfo_t *si, int parc, char *parv[]);
23    
24 pippijn 1.6 command_t const os_mode = { "MODE", N_("Changes modes on channels."), PRIV_OMODE, 2, os_cmd_mode };
25 pippijn 1.1
26 pippijn 1.6 E cmdvec os_cmdtree;
27     E helpvec os_helptree;
28 pippijn 1.1
29 pippijn 1.6 bool
30     _modinit (module *m)
31 pippijn 1.1 {
32     os_cmdtree << os_mode;
33 pippijn 1.4 help_addentry (os_helptree, "MODE", "help/operserv/mode", NULL);
34 pippijn 1.6
35     return true;
36 pippijn 1.1 }
37    
38     void
39     _moddeinit ()
40     {
41     os_cmdtree >> os_mode;
42     help_delentry (os_helptree, "MODE");
43     }
44    
45     static void
46     os_cmd_mode (sourceinfo_t *si, int parc, char *parv[])
47     {
48     char *channel = parv[0];
49     char *mode = parv[1];
50     channel_t *c;
51     int modeparc;
52     char *modeparv[256];
53    
54     if (!channel || !mode)
55     {
56 pippijn 1.7 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MODE");
57     command_fail (si, fault::needmoreparams, _("Syntax: MODE <channel> <parameters>"));
58 pippijn 1.1 return;
59     }
60    
61     c = channel_find (channel);
62     if (!c)
63     {
64 pippijn 1.7 command_fail (si, fault::nosuch_target, _("Channel \2%s\2 does not exist."), channel);
65 pippijn 1.1 return;
66     }
67    
68     wallops ("\2%s\2 is using MODE on \2%s\2 (set: \2%s\2)", get_oper_name (si), channel, mode);
69     snoop ("MODE: \2%s\2 \2%s\2 by \2%s\2", channel, mode, get_oper_name (si));
70     logcommand (si, CMDLOG_ADMIN, "MODE %s %s", channel, mode);
71    
72     modeparc = sjtoken (mode, ' ', modeparv);
73    
74     channel_mode (si->service->me, c, modeparc, modeparv);
75     command_success_nodata (si, _("Set modes \2%s\2 on \2%s\2."), mode, channel);
76     }