Anope IRC Services  Version 1.8
ms_sendall.c
Go to the documentation of this file.
1 /* MemoServ 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_sendall(User * u);
18 static void myMemoServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
32  (VERSION_STRING);
34  c = createCommand("SENDALL", do_sendall, is_services_admin, -1, -1, -1,
35  MEMO_HELP_SENDALL, MEMO_HELP_SENDALL);
38 
39  return MOD_CONT;
40 }
41 
45 void AnopeFini(void)
46 {
47 
48 }
49 
50 
51 
56 static void myMemoServHelp(User * u)
57 {
58  if (is_services_admin(u)) {
59  notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SENDALL);
60  }
61 }
62 
68 static int do_sendall(User * u)
69 {
70  int i, z = 1;
71  NickCore *nc;
72  char *text = strtok(NULL, "");
73 
74  if (readonly) {
75  notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
76  return MOD_CONT;
77  } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
78  notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED);
79  return MOD_CONT;
80  } else if (!text) {
81  syntax_error(s_MemoServ, u, "SENDALL", MEMO_SEND_SYNTAX);
82  return MOD_CONT;
83  }
84 
85 
86  for (i = 0; i < 1024; i++) {
87  for (nc = nclists[i]; nc; nc = nc->next) {
88  if (stricmp(u->nick, nc->display) != 0)
89  memo_send(u, nc->display, text, z);
90  } /* /nc */
91  } /* /i */
92 
93  alog("%s: %s!%s@%s sent a mass memo",
94  s_MemoServ, u->nick, u->username, u->host);
95  notice_lang(s_MemoServ, u, MEMO_MASS_SENT);
96  return MOD_CONT;
97 }
E int readonly
Definition: extern.h:776
char nick[NICKMAX]
Definition: services.h:875
E int checkDefCon(int level)
Definition: operserv.c:1608
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
void AnopeFini(void)
Definition: ms_sendall.c:45
char * host
Definition: services.h:878
static void myMemoServHelp(User *u)
Definition: ms_sendall.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
char * display
Definition: services.h:542
MDE void moduleSetMemoHelp(void(*func)(User *u))
Definition: modules.c:2102
E char * s_MemoServ
Definition: extern.h:286
int AnopeInit(int argc, char **argv)
Definition: ms_sendall.c:26
NickCore * next
Definition: services.h:540
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
E int is_services_admin(User *u)
Definition: operserv.c:591
char * username
Definition: services.h:877
#define DEFCON_NO_NEW_MEMOS
Definition: services.h:1263
#define MEMOSERV
Definition: modules.h:58
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 memo_send(User *u, char *name, char *text, int z)
Definition: memoserv.c:198
E NickCore * nclists[1024]
Definition: extern.h:924
static int do_sendall(User *u)
Definition: ms_sendall.c:68
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define MOD_UNIQUE
Definition: module.h:11