Anope IRC Services  Version 1.8
os_umode.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_operumodes(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 
35  OPER_HELP_UMODE, -1, -1, -1, -1);
37 
39 
40  if (!ircd->umode) {
41  return MOD_STOP;
42  }
43  return MOD_CONT;
44 }
45 
49 void AnopeFini(void)
50 {
51 
52 }
53 
54 
59 static void myOperServHelp(User * u)
60 {
61  if (is_services_admin(u) && u->isSuperAdmin) {
62  notice_lang(s_OperServ, u, OPER_HELP_CMD_UMODE);
63  }
64 }
65 
74 static int do_operumodes(User * u)
75 {
76  char *nick = strtok(NULL, " ");
77  char *modes = strtok(NULL, "");
78 
79  User *u2;
80 
81  /* Only allow this if SuperAdmin is enabled */
82  if (!u->isSuperAdmin) {
83  notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
84  return MOD_CONT;
85  }
86 
87  if (!nick || !modes) {
88  syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
89  return MOD_CONT;
90  }
91 
96  if ((modes[0] != '+') && (modes[0] != '-')) {
97  syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
98  return MOD_CONT;
99  }
100  if (!(u2 = finduser(nick))) {
101  notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
102  } else {
103  common_svsmode(u2, modes, NULL);
104 
105  notice_lang(s_OperServ, u, OPER_UMODE_SUCCESS, nick);
106  notice_lang(s_OperServ, u2, OPER_UMODE_CHANGED, u->nick);
107 
108  if (WallOSMode)
109  anope_cmd_global(s_OperServ, "\2%s\2 used UMODE on %s",
110  u->nick, nick);
111  }
112  return MOD_CONT;
113 }
char nick[NICKMAX]
Definition: services.h:875
E IRCDVar * ircd
Definition: extern.h:39
static int do_operumodes(User *u)
Definition: os_umode.c:74
static void myOperServHelp(User *u)
Definition: os_umode.c:59
int AnopeInit(int argc, char **argv)
Definition: os_umode.c:26
int isSuperAdmin
Definition: services.h:896
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
int umode
Definition: services.h:342
E int is_services_root(User *u)
Definition: operserv.c:577
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
#define MOD_STOP
Definition: modules.h:53
E User * finduser(const char *nick)
Definition: users.c:323
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
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
E void common_svsmode(User *u, char *modes, char *arg)
Definition: actions.c:228
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
E int WallOSMode
Definition: extern.h:451
void AnopeFini(void)
Definition: os_umode.c:49
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506