| 1 |
pippijn |
1.1 |
/* |
| 2 |
pippijn |
1.6 |
* Copyright © 2005-2006 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 |
pippijn |
1.6 |
* This file contains functionality which implements the OperServ MODE command. |
| 6 |
pippijn |
1.1 |
* |
| 7 |
pippijn |
1.6 |
* $Id: mode.C,v 1.5 2007-07-25 00:03:21 pippijn Exp $ |
| 8 |
pippijn |
1.1 |
*/ |
| 9 |
|
|
|
| 10 |
|
|
#include "atheme.h" |
| 11 |
pippijn |
1.6 |
#include <ermyth/module.h> |
| 12 |
pippijn |
1.1 |
|
| 13 |
pippijn |
1.6 |
static char const rcsid[] = "$Id: mode.C,v 1.5 2007-07-25 00:03:21 pippijn Exp $"; |
| 14 |
pippijn |
1.1 |
|
| 15 |
pippijn |
1.6 |
REGISTER_MODULE ("operserv/mode", false, "The Ermyth Team <http://ermyth.schmorp.de>"); |
| 16 |
pippijn |
1.1 |
|
| 17 |
|
|
static void os_cmd_mode (sourceinfo_t *si, int parc, char *parv[]); |
| 18 |
|
|
|
| 19 |
pippijn |
1.6 |
command_t const os_mode = { "MODE", N_("Changes modes on channels."), PRIV_OMODE, 2, os_cmd_mode }; |
| 20 |
pippijn |
1.1 |
|
| 21 |
pippijn |
1.6 |
E cmdvec os_cmdtree; |
| 22 |
|
|
E helpvec os_helptree; |
| 23 |
pippijn |
1.1 |
|
| 24 |
pippijn |
1.6 |
bool |
| 25 |
|
|
_modinit (module *m) |
| 26 |
pippijn |
1.1 |
{ |
| 27 |
|
|
os_cmdtree << os_mode; |
| 28 |
pippijn |
1.4 |
help_addentry (os_helptree, "MODE", "help/operserv/mode", NULL); |
| 29 |
pippijn |
1.6 |
|
| 30 |
|
|
return true; |
| 31 |
pippijn |
1.1 |
} |
| 32 |
|
|
|
| 33 |
|
|
void |
| 34 |
|
|
_moddeinit () |
| 35 |
|
|
{ |
| 36 |
|
|
os_cmdtree >> os_mode; |
| 37 |
|
|
help_delentry (os_helptree, "MODE"); |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
static void |
| 41 |
|
|
os_cmd_mode (sourceinfo_t *si, int parc, char *parv[]) |
| 42 |
|
|
{ |
| 43 |
|
|
char *channel = parv[0]; |
| 44 |
|
|
char *mode = parv[1]; |
| 45 |
|
|
channel_t *c; |
| 46 |
|
|
int modeparc; |
| 47 |
|
|
char *modeparv[256]; |
| 48 |
|
|
|
| 49 |
|
|
if (!channel || !mode) |
| 50 |
|
|
{ |
| 51 |
|
|
command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODE"); |
| 52 |
|
|
command_fail (si, fault_needmoreparams, _("Syntax: MODE <channel> <parameters>")); |
| 53 |
|
|
return; |
| 54 |
|
|
} |
| 55 |
|
|
|
| 56 |
|
|
c = channel_find (channel); |
| 57 |
|
|
if (!c) |
| 58 |
|
|
{ |
| 59 |
|
|
command_fail (si, fault_nosuch_target, _("Channel \2%s\2 does not exist."), channel); |
| 60 |
|
|
return; |
| 61 |
|
|
} |
| 62 |
|
|
|
| 63 |
|
|
wallops ("\2%s\2 is using MODE on \2%s\2 (set: \2%s\2)", get_oper_name (si), channel, mode); |
| 64 |
|
|
snoop ("MODE: \2%s\2 \2%s\2 by \2%s\2", channel, mode, get_oper_name (si)); |
| 65 |
|
|
logcommand (si, CMDLOG_ADMIN, "MODE %s %s", channel, mode); |
| 66 |
|
|
|
| 67 |
|
|
modeparc = sjtoken (mode, ' ', modeparv); |
| 68 |
|
|
|
| 69 |
|
|
channel_mode (si->service->me, c, modeparc, modeparv); |
| 70 |
|
|
command_success_nodata (si, _("Set modes \2%s\2 on \2%s\2."), mode, channel); |
| 71 |
|
|
} |