Anope IRC Services  Version 1.8
os_noop.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_noop(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("NOOP", do_noop, is_services_admin, OPER_HELP_NOOP,
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_admin(u)) {
59  notice_lang(s_OperServ, u, OPER_HELP_CMD_NOOP);
60  }
61 }
62 
68 static int do_noop(User * u)
69 {
70  char *cmd = strtok(NULL, " ");
71  char *server = strtok(NULL, " ");
72 
73  if (!cmd || !server) {
74  syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
75  } else if (!stricmp(cmd, "SET")) {
76  User *u2;
77  User *u3 = NULL;
78  char reason[NICKMAX + 32];
79 
80  /* Remove the O:lines */
81  anope_cmd_svsnoop(server, 1);
82 
83  snprintf(reason, sizeof(reason), "NOOP command used by %s",
84  u->nick);
85  if (WallOSNoOp)
86  anope_cmd_global(s_OperServ, "\2%s\2 used NOOP on \2%s\2",
87  u->nick, server);
88  notice_lang(s_OperServ, u, OPER_NOOP_SET, server);
89 
90  /* Kill all the IRCops of the server */
91  for (u2 = firstuser(); u2; u2 = u3) {
92  u3 = nextuser();
93  if ((u2) && is_oper(u2) && (u2->server->name)
94  && match_wild(server, u2->server->name)) {
95  kill_user(s_OperServ, u2->nick, reason);
96  }
97  }
98  } else if (!stricmp(cmd, "REVOKE")) {
99  anope_cmd_svsnoop(server, 0);
100  notice_lang(s_OperServ, u, OPER_NOOP_REVOKE, server);
101  } else {
102  syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
103  }
104  return MOD_CONT;
105 }
E int is_oper(User *user)
Definition: users.c:937
E User * nextuser(void)
Definition: users.c:364
char nick[NICKMAX]
Definition: services.h:875
E int snprintf(char *buf, size_t size, const char *fmt,...)
Definition: compat.c:37
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
void AnopeFini(void)
Definition: os_noop.c:46
static void myOperServHelp(User *u)
Definition: os_noop.c:56
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 void kill_user(char *source, char *user, char *reason)
Definition: actions.c:51
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
char * name
Definition: services.h:854
Command * c
Definition: ns_recover.c:17
Server * server
Definition: services.h:884
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
E User * firstuser(void)
Definition: users.c:352
int AnopeInit(int argc, char **argv)
Definition: os_noop.c:26
E int is_services_admin(User *u)
Definition: operserv.c:591
E int WallOSNoOp
Definition: extern.h:458
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 int do_noop(User *u)
Definition: os_noop.c:68
#define NICKMAX
Definition: config.h:62
E void anope_cmd_svsnoop(char *server, int set)
Definition: ircd.c:135
E int match_wild(const char *pattern, const char *str)
Definition: misc.c:255
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506