ms_sendall.c

Go to the documentation of this file.
00001 /* MemoServ 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_sendall(User * u);
00018 static void myMemoServHelp(User * u);
00019 
00026 int AnopeInit(int argc, char **argv)
00027 {
00028     Command *c;
00029 
00030     moduleAddAuthor("Anope");
00031     moduleAddVersion
00032         (VERSION_STRING);
00033     moduleSetType(CORE);
00034     c = createCommand("SENDALL", do_sendall, is_services_admin, -1, -1, -1,
00035                       MEMO_HELP_SENDALL, MEMO_HELP_SENDALL);
00036     moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
00037     moduleSetMemoHelp(myMemoServHelp);
00038 
00039     return MOD_CONT;
00040 }
00041 
00045 void AnopeFini(void)
00046 {
00047 
00048 }
00049 
00050 
00051 
00056 static void myMemoServHelp(User * u)
00057 {
00058     if (is_services_admin(u)) {
00059         notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SENDALL);
00060     }
00061 }
00062 
00068 static int do_sendall(User * u)
00069 {
00070     int i, z = 1;
00071     NickCore *nc;
00072     char *text = strtok(NULL, "");
00073 
00074     if (readonly) {
00075         notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
00076         return MOD_CONT;
00077     } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
00078         notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED);
00079         return MOD_CONT;
00080     } else if (!text) {
00081         syntax_error(s_MemoServ, u, "SENDALL", MEMO_SEND_SYNTAX);
00082         return MOD_CONT;
00083     }
00084 
00085 
00086     for (i = 0; i < 1024; i++) {
00087         for (nc = nclists[i]; nc; nc = nc->next) {
00088             if (stricmp(u->nick, nc->display) != 0)
00089                 memo_send(u, nc->display, text, z);
00090         }                       /* /nc */
00091     }                           /* /i */
00092 
00093     alog("%s: %s!%s@%s sent a mass memo",
00094          s_MemoServ, u->nick, u->username, u->host);
00095     notice_lang(s_MemoServ, u, MEMO_MASS_SENT);
00096     return MOD_CONT;
00097 }