Anope IRC Services  Version 1.8
os_mode.c
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 static int do_os_mode(User * u);
18 static void myOperServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
34  c = createCommand("MODE", do_os_mode, is_services_oper, OPER_HELP_MODE,
35  -1, -1, -1, -1);
37 
39 
40  return MOD_CONT;
41 }
42 
46 void AnopeFini(void)
47 {
48 
49 }
50 
51 
56 static void myOperServHelp(User * u)
57 {
58  if (is_services_oper(u)) {
59  notice_lang(s_OperServ, u, OPER_HELP_CMD_MODE);
60  }
61 }
62 
68 static int do_os_mode(User * u)
69 {
70  int ac;
71  char **av;
72  char *chan = strtok(NULL, " "), *modes = strtok(NULL, "");
73  Channel *c;
74 
75  if (!chan || !modes) {
76  syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
77  return MOD_CONT;
78  }
79 
80  if (!(c = findchan(chan))) {
81  notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
82  } else if (c->bouncy_modes) {
83  notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
84  return MOD_CONT;
85  } else if ((ircd->adminmode) && (!is_services_admin(u))
86  && (c->mode & ircd->adminmode)) {
87  notice_lang(s_OperServ, u, PERMISSION_DENIED);
88  return MOD_CONT;
89  } else {
90  anope_cmd_mode(s_OperServ, chan, "%s", modes);
91 
92  ac = split_buf(modes, &av, 1);
93  chan_set_modes(s_OperServ, c, ac, av, -1);
94  free(av);
95 
96  if (WallOSMode)
97  anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick,
98  modes, chan);
99  }
100  return MOD_CONT;
101 }
int AnopeInit(int argc, char **argv)
Definition: os_mode.c:26
char nick[NICKMAX]
Definition: services.h:875
E IRCDVar * ircd
Definition: extern.h:39
E void chan_set_modes(const char *source, Channel *chan, int ac, char **av, int check)
Definition: channels.c:161
void AnopeFini(void)
Definition: os_mode.c:46
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E Channel * findchan(const char *chan)
Definition: channels.c:394
int16 bouncy_modes
Definition: services.h:1028
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
uint32 adminmode
Definition: services.h:346
uint32 mode
Definition: services.h:1006
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
E int is_services_admin(User *u)
Definition: operserv.c:591
E int split_buf(char *buf, char ***argv, int colon_special)
Definition: process.c:270
E void anope_cmd_mode(char *source, char *dest, const char *fmt,...)
Definition: ircd.c:211
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
static void myOperServHelp(User *u)
Definition: os_mode.c:56
static int do_os_mode(User *u)
Definition: os_mode.c:68
E int is_services_oper(User *u)
Definition: operserv.c:606
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
E int WallOSMode
Definition: extern.h:451
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506