os_noop.c

Go to the documentation of this file.
00001 /* OperServ core functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 /*************************************************************************/
00014 
00015 #include "module.h"
00016 
00017 static int do_noop(User * u);
00018 static void myOperServHelp(User * u);
00019 
00026 int AnopeInit(int argc, char **argv)
00027 {
00028     Command *c;
00029 
00030     moduleAddAuthor("Anope");
00031     moduleAddVersion(VERSION_STRING);
00032     moduleSetType(CORE);
00033 
00034     c = createCommand("NOOP", do_noop, is_services_admin, OPER_HELP_NOOP,
00035                       -1, -1, -1, -1);
00036     moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
00037 
00038     moduleSetOperHelp(myOperServHelp);
00039 
00040     return MOD_CONT;
00041 }
00042 
00046 void AnopeFini(void)
00047 {
00048 
00049 }
00050 
00051 
00056 static void myOperServHelp(User * u)
00057 {
00058     if (is_services_admin(u)) {
00059         notice_lang(s_OperServ, u, OPER_HELP_CMD_NOOP);
00060     }
00061 }
00062 
00068 static int do_noop(User * u)
00069 {
00070     char *cmd = strtok(NULL, " ");
00071     char *server = strtok(NULL, " ");
00072 
00073     if (!cmd || !server) {
00074         syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
00075     } else if (!stricmp(cmd, "SET")) {
00076         User *u2;
00077         User *u3 = NULL;
00078         char reason[NICKMAX + 32];
00079 
00080         /* Remove the O:lines */
00081         anope_cmd_svsnoop(server, 1);
00082 
00083         snprintf(reason, sizeof(reason), "NOOP command used by %s",
00084                  u->nick);
00085         if (WallOSNoOp)
00086             anope_cmd_global(s_OperServ, "\2%s\2 used NOOP on \2%s\2",
00087                              u->nick, server);
00088         notice_lang(s_OperServ, u, OPER_NOOP_SET, server);
00089 
00090         /* Kill all the IRCops of the server */
00091         for (u2 = firstuser(); u2; u2 = u3) {
00092             u3 = nextuser();
00093             if ((u2) && is_oper(u2) && (u2->server->name)
00094                 && match_wild(server, u2->server->name)) {
00095                 kill_user(s_OperServ, u2->nick, reason);
00096             }
00097         }
00098     } else if (!stricmp(cmd, "REVOKE")) {
00099         anope_cmd_svsnoop(server, 0);
00100         notice_lang(s_OperServ, u, OPER_NOOP_REVOKE, server);
00101     } else {
00102         syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
00103     }
00104     return MOD_CONT;
00105 }