Anope IRC Services  Version 1.8
ms_rsend.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_rsend(User * u);
18 static void myMemoServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  if (!MSMemoReceipt) {
31  alog("MSMemoReceipt not enabled in services.conf");
32  return MOD_STOP;
33  }
34 
35  moduleAddAuthor("Anope");
37  (VERSION_STRING);
39  c = createCommand("RSEND", do_rsend, NULL, MEMO_HELP_RSEND, -1, -1, -1,
40  -1);
43 
44 
45  return MOD_CONT;
46 }
47 
51 void AnopeFini(void)
52 {
53 
54 }
55 
60 static void myMemoServHelp(User * u)
61 {
62  if (((MSMemoReceipt == 1) && (is_services_oper(u)))
63  || (MSMemoReceipt == 2)) {
64  notice_lang(s_MemoServ, u, MEMO_HELP_CMD_RSEND);
65  }
66 }
67 
73 static int do_rsend(User * u)
74 {
75  char *name = strtok(NULL, " ");
76  char *text = strtok(NULL, "");
77  NickAlias *na = NULL;
78  int z = 3;
79 
80 
81 
82  /* check if the variables are here */
83  if (!name || !text) {
84  syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX);
85  return MOD_CONT;
86  }
87 
88  /* prevent user from rsend to themselves */
89  if ((na = findnick(name))) {
90  if (u->na) {
91  if (stricmp(na->nc->display, u->na->nc->display) == 0) {
92  notice_lang(s_MemoServ, u, MEMO_NO_RSEND_SELF);
93  return MOD_CONT;
94  }
95  } else {
96  notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name);
97  return MOD_CONT;
98  }
99  }
100 
101  if (MSMemoReceipt == 1) {
102  /* Services opers and above can use rsend */
103  if (is_services_oper(u)) {
104  memo_send(u, name, text, z);
105  } else {
106  notice_lang(s_MemoServ, u, ACCESS_DENIED);
107  }
108  } else if (MSMemoReceipt == 2) {
109  /* Everybody can use rsend */
110  memo_send(u, name, text, z);
111  } else {
112  /* rsend has been disabled */
113  if (debug) {
114  alog("debug: MSMemoReceipt is set misconfigured to %d",
115  MSMemoReceipt);
116  }
117  notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED);
118  }
119 
120  return MOD_CONT;
121 }
E NickAlias * findnick(const char *nick)
Definition: db-merger.c:1857
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
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
NickCore * nc
Definition: services.h:533
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
#define MOD_STOP
Definition: modules.h:53
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
void AnopeFini(void)
Definition: ms_rsend.c:51
static int do_rsend(User *u)
Definition: ms_rsend.c:73
int AnopeInit(int argc, char **argv)
Definition: ms_rsend.c:26
E int debug
Definition: extern.h:775
E int MSMemoReceipt
Definition: extern.h:418
#define MEMOSERV
Definition: modules.h:58
static void myMemoServHelp(User *u)
Definition: ms_rsend.c:60
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 int is_services_oper(User *u)
Definition: operserv.c:606
E void memo_send(User *u, char *name, char *text, int z)
Definition: memoserv.c:198
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
NickAlias * na
Definition: services.h:892
#define MOD_UNIQUE
Definition: module.h:11