summaryrefslogtreecommitdiff
path: root/src/memoserv.c
diff options
context:
space:
mode:
authortrystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2004-10-03 03:58:43 +0000
committertrystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2004-10-03 03:58:43 +0000
commit04afc8548091ab4a5ee405dbe40c5ad1ab9f5d98 (patch)
tree61d5157b8f6f1cc9bfa202dc13ab155702f652b9 /src/memoserv.c
parent7bc5f4a8ed453f1e6922e71a7066f02c8ffc7484 (diff)
BUILD : 1.7.5 (365) BUGS : 172 NOTES : - New directive NewsCount - fr.l updated - do_memocheck() globalized the time display - getmemoinfo() improved to return info about being forbidden - fixes svsnick on Unreal - anope_event_null to allow ircd devs to point events that go to no where some where - fixed SQUIT
git-svn-id: svn://svn.anope.org/anope/trunk@365 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@236 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/memoserv.c')
-rw-r--r--src/memoserv.c76
1 files changed, 53 insertions, 23 deletions
diff --git a/src/memoserv.c b/src/memoserv.c
index 131c48d48..9e9612d8e 100644
--- a/src/memoserv.c
+++ b/src/memoserv.c
@@ -154,28 +154,45 @@ void check_memos(User * u)
/* Return the MemoInfo corresponding to the given nick or channel name.
* Return in `ischan' 1 if the name was a channel name, else 0.
+ * Return in `isforbid' 1 if the name is forbidden, else 0.
*/
-static MemoInfo *getmemoinfo(const char *name, int *ischan)
+static MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid)
{
if (*name == '#') {
ChannelInfo *ci;
if (ischan)
*ischan = 1;
ci = cs_findchan(name);
- if (ci && !(ci->flags & CI_VERBOTEN))
- return &ci->memos;
- else
+ if (ci) {
+ if (!(ci->flags & CI_VERBOTEN)) {
+ *isforbid = 0;
+ return &ci->memos;
+ } else {
+ *isforbid = 1;
+ return NULL;
+ }
+ } else {
+ *isforbid = 0;
return NULL;
+ }
} else {
NickAlias *na;
if (ischan)
*ischan = 0;
na = findnick(name);
- if (na && !(na->status & NS_VERBOTEN))
- return &na->nc->memos;
- else
+ if (na) {
+ if (!(na->status & NS_VERBOTEN)) {
+ *isforbid = 0;
+ return &na->nc->memos;
+ } else {
+ *isforbid = 1;
+ return NULL;
+ }
+ } else {
+ *isforbid = 0;
return NULL;
+ }
}
}
@@ -261,6 +278,7 @@ static int do_send(User * u)
void memo_send(User * u, char *name, char *text, int z)
{
int ischan;
+ int isforbid;
Memo *m;
MemoInfo *mi;
time_t now = time(NULL);
@@ -284,11 +302,17 @@ void memo_send(User * u, char *name, char *text, int z)
if (z == 0 || z == 3)
notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (!(mi = getmemoinfo(name, &ischan))) {
+ } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) {
if (z == 0 || z == 3)
- notice_lang(s_MemoServ, u,
- ischan ? CHAN_X_NOT_REGISTERED :
- NICK_X_NOT_REGISTERED, name);
+ if (isforbid) {
+ notice_lang(s_MemoServ, u,
+ ischan ? CHAN_X_FORBIDDEN :
+ NICK_X_FORBIDDEN, name);
+ } else {
+ notice_lang(s_MemoServ, u,
+ ischan ? CHAN_X_NOT_REGISTERED :
+ NICK_X_NOT_REGISTERED, name);
+ }
} else if (z != 2 && MSSendDelay > 0 &&
u && u->lastmemosend + MSSendDelay > now && !is_servoper) {
@@ -390,6 +414,7 @@ void memo_send(User * u, char *name, char *text, int z)
static int do_cancel(User * u)
{
int ischan;
+ int isforbid;
char *name = strtok(NULL, " ");
MemoInfo *mi;
@@ -399,10 +424,16 @@ static int do_cancel(User * u)
} else if (!nick_recognized(u)) {
notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (!(mi = getmemoinfo(name, &ischan))) {
- notice_lang(s_MemoServ, u,
- ischan ? CHAN_X_NOT_REGISTERED : NICK_X_NOT_REGISTERED,
- name);
+ } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) {
+ if (isforbid) {
+ notice_lang(s_MemoServ, u,
+ ischan ? CHAN_X_FORBIDDEN :
+ NICK_X_FORBIDDEN, name);
+ } else {
+ notice_lang(s_MemoServ, u,
+ ischan ? CHAN_X_NOT_REGISTERED :
+ NICK_X_NOT_REGISTERED, name);
+ }
} else {
int i;
@@ -1335,8 +1366,9 @@ static int do_memocheck(User * u)
NickAlias *na = NULL;
MemoInfo *mi = NULL;
int i, found = 0;
- char *stime = NULL;
char *recipient = strtok(NULL, "");
+ struct tm *tm;
+ char timebuf[64];
if (!recipient) {
syntax_error(s_MemoServ, u, "CHECK", MEMO_CHECK_SYNTAX);
@@ -1358,15 +1390,16 @@ static int do_memocheck(User * u)
if (!stricmp(mi->memos[i].sender, u->nick)) {
found = 1; /* Yes, we've found the memo */
- stime = strdup(ctime(&mi->memos[i].time));
- *(stime + strlen(stime) - 1) = ' '; /* cut the f*cking \0 terminator and replace it with a single space */
+ tm = localtime(&mi->memos[i].time);
+ strftime_lang(timebuf, sizeof(timebuf), u,
+ STRFTIME_DATE_TIME_FORMAT, tm);
if (mi->memos[i].flags & MF_UNREAD)
notice_lang(s_MemoServ, u, MEMO_CHECK_NOT_READ, na->nick,
- stime);
+ timebuf);
else
notice_lang(s_MemoServ, u, MEMO_CHECK_READ, na->nick,
- stime);
+ timebuf);
break;
}
}
@@ -1374,9 +1407,6 @@ static int do_memocheck(User * u)
if (!found)
notice_lang(s_MemoServ, u, MEMO_CHECK_NO_MEMO, na->nick);
- if (stime)
- free(stime);
-
return MOD_CONT;
}