diff options
author | atoledo atoledo@31f1291d-b8d6-0310-a050-a5561fc1590b <atoledo atoledo@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-04-26 21:07:33 +0000 |
---|---|---|
committer | atoledo atoledo@31f1291d-b8d6-0310-a050-a5561fc1590b <atoledo atoledo@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-04-26 21:07:33 +0000 |
commit | 98167888fafe2793b9fded5b9af1eecc8efae0ba (patch) | |
tree | 60bca39ca5312e842b2c83b2abd26f3054600b60 | |
parent | 35932944badfb8d3985b798c9ed975dcdf8d1d95 (diff) |
BUILD : 1.7.2 (69) BUGS : NOTES : Added new MemoServ command RSEND to send a memo requesting a receipt memo once the recipient reads it.
git-svn-id: svn://svn.anope.org/anope/trunk@69 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@45 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | Changes.conf | 8 | ||||
-rw-r--r-- | Changes.lang | 8 | ||||
-rw-r--r-- | config.c | 2 | ||||
-rw-r--r-- | data/example.conf | 7 | ||||
-rw-r--r-- | extern.h | 1 | ||||
-rw-r--r-- | lang/en_us.l | 27 | ||||
-rw-r--r-- | memoserv.c | 162 | ||||
-rw-r--r-- | services.h | 1 | ||||
-rw-r--r-- | version.log | 6 |
10 files changed, 217 insertions, 6 deletions
@@ -1,6 +1,7 @@ Anope Version 1.7.x (will be renamed when next release is produced) ------------------- Provided by Anope Dev. <dev@anope.org> +2004/04/23 Added new MemoServ command RSEND to send a memo requesting a receipt memo once the recipient reads it. 2004/04/22 Fixed ALIST bug when being invoked by systems admins (Bug #20) 2004/04/19 Added /bin/anoperc anope console control script diff --git a/Changes.conf b/Changes.conf index 5f94cc0ab..6e0e6ab5f 100644 --- a/Changes.conf +++ b/Changes.conf @@ -1,5 +1,13 @@ Anope Version 1.7.x (will be renamed when next release is produced) ------------------- +** ADDED CONFIGURATION DIRECTIVES ** + +# MSMemoReceipt [OPTIONAL] +# Allow the use of memo receipts for the following groups: +# 1 - Opers Only +# 2 - Everybody +# +#MSMemoReceipt 1 Anope Version 1.7.2 -------------------- diff --git a/Changes.lang b/Changes.lang index 98ae26f41..2c32c1d40 100644 --- a/Changes.lang +++ b/Changes.lang @@ -1,5 +1,13 @@ Anope Version 1.7.x (will be renamed when next release is produced) ------------------- +*** New Strings: + +MEMO_RSEND_PLEASE_WAIT +MEMO_RSEND_DISABLED +MEMO_RSEND_SYNTAX +MEMO_RSEND_NICK_MEMO_TEXT +MEMO_RSEND_CHAN_MEMO_TEXT +MEMO_RSEND_USER_NOTIFICATION Anope Version 1.7.2 -------------------- @@ -205,6 +205,7 @@ int CSOpersOnly; int MSMaxMemos; int MSSendDelay; int MSNotifyAll; +int MSMemoReceipt; int BSDefDontKickOps; int BSDefDontKickVoices; @@ -495,6 +496,7 @@ Directive directives[] = { {"MSMaxMemos", {{PARAM_POSINT, PARAM_RELOAD, &MSMaxMemos}}}, {"MSNotifyAll", {{PARAM_SET, PARAM_RELOAD, &MSNotifyAll}}}, {"MSSendDelay", {{PARAM_TIME, PARAM_RELOAD, &MSSendDelay}}}, + {"MSMemoReceipt", {{PARAM_POSINT, PARAM_RELOAD, &MSMemoReceipt}}}, {"NetworkDomain", {{PARAM_STRING, PARAM_RELOAD, &NetworkDomain}}}, {"NetworkName", {{PARAM_STRING, PARAM_RELOAD, &NetworkName}}}, {"NewsDB", {{PARAM_STRING, PARAM_RELOAD, &NewsDBName}}}, diff --git a/data/example.conf b/data/example.conf index 333dc41d3..db83e27f7 100644 --- a/data/example.conf +++ b/data/example.conf @@ -946,6 +946,13 @@ MSSendDelay 3s MSNotifyAll +# MSMemoReceipt [OPTIONAL] +# Allow the use of memo receipts for the following groups: +# 1 - Opers Only +# 2 - Everybody +# +#MSMemoReceipt 1 + ########################################################################### # # BotServ configuration @@ -344,6 +344,7 @@ E int CSOpersOnly; E int MSMaxMemos; E int MSSendDelay; E int MSNotifyAll; +E int MSMemoReceipt; E int BSDefFlags; E int BSKeepData; diff --git a/lang/en_us.l b/lang/en_us.l index e103802e0..fa3348597 100644 --- a/lang/en_us.l +++ b/lang/en_us.l @@ -1711,6 +1711,21 @@ MEMO_MAIL_TEXT2 MEMO_MAIL_TEXT3 Memo Text: +# RSEND responses +MEMO_RSEND_PLEASE_WAIT + Please wait %d seconds before using the RSEND command again. +MEMO_RSEND_DISABLED + Sorry, RSEND has been disabled on this network. +MEMO_RSEND_SYNTAX + RSEND {nick | channel} memo-text +MEMO_RSEND_NICK_MEMO_TEXT + Your memo sent to %s has been read. +MEMO_RSEND_CHAN_MEMO_TEXT + Your memo sent to %s has been read by %s. +MEMO_RSEND_USER_NOTIFICATION + A notification memo has been sent to %s informing him/her you have + read his/her memo. + ########################################################################### # # BotServ messages @@ -4639,6 +4654,7 @@ MEMO_HELP DEL Delete a memo or memos SET Set options related to memos INFO Displays information about your memos + RSEND Sends a memo and requests a read receipt MEMO_HELP_ADMIN SENDALL Send a memo to all registered users @@ -4803,6 +4819,17 @@ MEMO_HELP_SENDALL Syntax: SENDALL memo-text Sends all registered users a memo containing memo-text. + +MEMO_HELP_RSEND + Syntax: RSEND {nick | channel} memo-text + + Sends the named nick or channel a memo containing + memo-text. When sending to a nickname, the recipient will + receive a notice that he/she has a new memo. The target + nickname/channel must be registered. + Once the memo is read by its recepient, an automatic notification + memo will be sent to the sender informing him/her that the memo + has been read. ########################################################################### # diff --git a/memoserv.c b/memoserv.c index a6549b117..587b65a59 100644 --- a/memoserv.c +++ b/memoserv.c @@ -35,6 +35,8 @@ static int do_staff(User *u); static int do_sendall(User *u); void moduleAddMemoServCmds(void); static void new_memo_mail(NickCore *nc, Memo *m); +static int do_rsend(User *u); +void rsend_notify(User *u, Memo *m, const char *chan); /*************************************************************************/ void moduleAddMemoServCmds(void) { @@ -51,6 +53,7 @@ void moduleAddMemoServCmds(void) { c = createCommand("SET LIMIT", NULL, NULL, -1,MEMO_HELP_SET_LIMIT, MEMO_SERVADMIN_HELP_SET_LIMIT,MEMO_SERVADMIN_HELP_SET_LIMIT, MEMO_SERVADMIN_HELP_SET_LIMIT); addCoreCommand(MEMOSERV,c); c = createCommand("INFO", do_info, NULL, -1,MEMO_HELP_INFO, MEMO_SERVADMIN_HELP_INFO,MEMO_SERVADMIN_HELP_INFO, MEMO_SERVADMIN_HELP_INFO); addCoreCommand(MEMOSERV,c); c = createCommand("SENDALL", do_sendall, is_services_admin, MEMO_HELP_SENDALL, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c); + c = createCommand("RSEND", do_rsend, NULL, MEMO_HELP_RSEND, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c); } /*************************************************************************/ @@ -250,6 +253,7 @@ static int do_send(User * u) * 0 - reply to user * 1 - silent * 2 - silent with no delay timer + * 3 - reply to user and request read receipt **/ void memo_send(User * u, char *name, char *text, int z) { @@ -269,12 +273,15 @@ void memo_send(User * u, char *name, char *text, int z) if (z == 0) syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); + if (z == 3) + syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); + } else if (!nick_recognized(u)) { - if (z == 0) + if (z == 0 || z == 3) notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); } else if (!(mi = getmemoinfo(name, &ischan))) { - if (z == 0) + if (z == 0 || z == 3) notice_lang(s_MemoServ, u, ischan ? CHAN_X_NOT_REGISTERED : NICK_X_NOT_REGISTERED, name); @@ -285,13 +292,16 @@ void memo_send(User * u, char *name, char *text, int z) if (z == 0) notice_lang(s_MemoServ, u, MEMO_SEND_PLEASE_WAIT, MSSendDelay); + if (z == 3) + notice_lang(s_MemoServ, u, MEMO_RSEND_PLEASE_WAIT, MSSendDelay); + } else if (mi->memomax == 0 && !is_servadmin) { - if (z == 0) + if (z == 0 || z == 3) notice_lang(s_MemoServ, u, MEMO_X_GETS_NO_MEMOS, name); } else if (mi->memomax > 0 && mi->memocount >= mi->memomax && !is_servadmin) { - if (z == 0) + if (z == 0 || z == 3) notice_lang(s_MemoServ, u, MEMO_X_HAS_TOO_MANY_MEMOS, name); } else { @@ -313,7 +323,10 @@ void memo_send(User * u, char *name, char *text, int z) m->time = time(NULL); m->text = sstrdup(text); m->flags = MF_UNREAD; - if (z == 0) + /* Set receipt request flag */ + if (z == 3) + m->flags |= MF_RECEIPT; + if (z == 0 || z == 3) notice_lang(s_MemoServ, u, MEMO_SENT, name); if (!ischan) { NickAlias *na; @@ -545,6 +558,12 @@ static int read_memo(User * u, int index, MemoInfo * mi, const char *chan) m->sender, timebuf, s_MemoServ, m->number); notice_lang(s_MemoServ, u, MEMO_TEXT, m->text); m->flags &= ~MF_UNREAD; + + /* Check if a receipt notification was requested */ + if (m->flags && MF_RECEIPT) { + rsend_notify(u, m, chan); + } + return 1; } @@ -1214,3 +1233,136 @@ static void new_memo_mail(NickCore * nc, Memo * m) } /*************************************************************************/ +/* Send a memo to a nick/channel requesting a receipt. */ + +static int do_rsend(User * u) +{ + char *name = strtok(NULL, " "); + char *text = strtok(NULL, ""); + int z = 3; + + if (MSMemoReceipt == 1) { + /* Services opers and above can use rsend */ + if (is_services_oper(u)) { + memo_send(u, name, text, z); + } else { + notice_lang(s_MemoServ, u, ACCESS_DENIED); + } + } else if (MSMemoReceipt == 2) { + /* Everybody can use rsend */ + memo_send(u, name, text, z); + } else { + /* rsend has been disabled */ + notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED); + } + + return MOD_CONT; +} + +/*************************************************************************/ +/* Send receipt notification to sender. */ + +void rsend_notify(User *u, Memo *m, const char *chan) +{ + User *nu; + Memo *nm; + MemoInfo *nmi; + NickAlias *nna; + NickCore *nnc; + char text[256]; + const char *fmt; + int i; + + /* Only send receipt if memos are allowed */ + if ((!readonly) && (!checkDefCon(DEFCON_NO_NEW_MEMOS))) { + + /* Gather nick alias, nick core and memo info for sender */ + nna = findnick(m->sender); + nnc = nna->nc; + nmi = &nnc->memos; + + /* Increase the sender's memocount by one */ + nmi->memocount++; + + /* Allocate memory for the new memo */ + nmi->memos = srealloc(nmi->memos, + sizeof(Memo) * nmi->memocount); + + /* Grab the new memo pointer to work on it */ + nm = &nmi->memos[nmi->memocount - 1]; + + /* Sender is MemoServ */ + strscpy(nm->sender, s_MemoServ, NICKMAX); + + /* If the user has more than one memo, assign the new + memo the next available index */ + if (nmi->memocount > 1) { + nm->number = nm[-1].number + 1; + + /* If needed, reindex memos */ + if (nm->number < 1) { + for (i = 0; i < nmi->memocount; i++) { + nmi->memos[i].number = i + 1; + } + } + } else { + /* User has no memos. Use index 1 */ + nm->number = 1; + } + + /* Populate memo structure and set text */ + nm->time = time(NULL); + + /* Text of the memo varies if the recepient was a + nick or channel */ + if (chan) { + fmt = getstring(nna, MEMO_RSEND_CHAN_MEMO_TEXT); + sprintf(text, fmt, chan, u->na->nc->display); + } else { + fmt = getstring(nna, MEMO_RSEND_NICK_MEMO_TEXT); + sprintf(text, fmt, u->na->nc->display); + } + + nm->text = sstrdup(text); + nm->flags = MF_UNREAD; + + /* Notify recepient of the memo that a notification has + been sent to the sender */ + notice_lang(s_MemoServ, u, MEMO_RSEND_USER_NOTIFICATION, + nnc->display); + + /* Check to see if we're notifying all aliases in the sender's + group or just the sender */ + if (MSNotifyAll) { + if ((nnc->flags & NI_MEMO_RECEIVE) && + get_ignore(m->sender) == NULL) { + for (i = 0; i < nnc->aliases.count; i++) { + nna = nnc->aliases.list[i]; + if (nna->u && nick_identified(nna->u)) { + notice_lang(s_MemoServ, nna->u, + MEMO_NEW_MEMO_ARRIVED, + s_MemoServ, s_MemoServ, + nm->number); + } + } + } else { + /* Find the sender user via the display nick */ + nu = finduser(nnc->display); + + if (nick_identified(nu)) { + notice_lang(s_MemoServ, u, + MEMO_NEW_MEMO_ARRIVED, + s_MemoServ, s_MemoServ, + nm->number); + } + } + } + } + + /* Remove receipt flag from the original memo */ + m->flags &= ~MF_RECEIPT; + + return; +} + +/*************************************************************************/ diff --git a/services.h b/services.h index 624fcd770..cd00c7c15 100644 --- a/services.h +++ b/services.h @@ -202,6 +202,7 @@ struct memo_ { }; #define MF_UNREAD 0x0001 /* Memo has not yet been read */ +#define MF_RECEIPT 0x0002 /* Sender requested receipt */ typedef struct { int16 memocount, memomax; diff --git a/version.log b/version.log index 5a0a377ba..13d9ef4d4 100644 --- a/version.log +++ b/version.log @@ -8,11 +8,15 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="2" -VERSION_BUILD="68" +VERSION_BUILD="69" VERSION_EXTRA="" # $Log$ # +# BUILD : 1.7.2 (69) +# BUGS : +# NOTES : Added new MemoServ command RSEND to send a memo requesting a receipt memo once the recipient reads it. +# # BUILD : 1.7.2 (68) # BUGS : 20 # NOTES : Fixed ALIST bug when being invoked by systems admins |