1 |
/** |
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 |
* Copyright © 2005-2006 William Pitcock, et al. |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: mode.C,v 1.8 2007-09-16 18:54:44 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
|
18 |
static char const rcsid[] = "$Id: mode.C,v 1.8 2007-09-16 18:54:44 pippijn Exp $"; |
19 |
|
20 |
REGISTER_MODULE ("operserv/mode", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
21 |
|
22 |
static void os_cmd_mode (sourceinfo_t *si, int parc, char *parv[]); |
23 |
|
24 |
command_t const os_mode = { "MODE", N_("Changes modes on channels."), PRIV_OMODE, 2, os_cmd_mode }; |
25 |
|
26 |
E cmdvec os_cmdtree; |
27 |
E helpvec os_helptree; |
28 |
|
29 |
bool |
30 |
_modinit (module *m) |
31 |
{ |
32 |
os_cmdtree << os_mode; |
33 |
help_addentry (os_helptree, "MODE", "help/operserv/mode", NULL); |
34 |
|
35 |
return true; |
36 |
} |
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 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MODE"); |
57 |
command_fail (si, fault::needmoreparams, _("Syntax: MODE <channel> <parameters>")); |
58 |
return; |
59 |
} |
60 |
|
61 |
c = channel_find (channel); |
62 |
if (!c) |
63 |
{ |
64 |
command_fail (si, fault::nosuch_target, _("Channel \2%s\2 does not exist."), channel); |
65 |
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 |
} |