jdhore avatar jdhore committed 427bbb5

Tweak auto-accept:
* does not apply to NOTICE (as those may well be automated)
* mirrors +g behaviour so that no useless accept entries are added for services
* respects max_accept, if it would be exceeded the message is dropped with numeric 494
* check moved up so this is checked before floodcount/tgchange

Pulled from Charybdis upstream changeset 1388:b1ef26176350 done by jilles.

Comments (0)

Files changed (3)

include/numeric.h

 
 #define ERR_KICKNOREJOIN     495
 
+#define ERR_OWNMODE          494 /* from bahamut -- jilles */
+
 #define ERR_UMODEUNKNOWNFLAG 501
 #define ERR_USERSDONTMATCH   502
 

modules/core/m_message.c

 
 	if(MyClient(source_p))
 	{
+		/*
+		 * XXX: Controversial? Allow target users to send replies
+		 * through a +g.  Rationale is that people can presently use +g
+		 * as a way to taunt users, e.g. harass them and hide behind +g
+		 * as a way of griefing.  --nenolod
+		 */
+		if(p_or_n != NOTICE && MyClient(source_p) &&
+				IsSetCallerId(source_p) &&
+				!accept_message(target_p, source_p) &&
+				!IsOper(target_p))
+		{
+			if(rb_dlink_list_length(&source_p->localClient->allow_list) <
+					ConfigFileEntry.max_accept)
+			{
+				rb_dlinkAddAlloc(target_p, &source_p->localClient->allow_list);
+				rb_dlinkAddAlloc(source_p, &target_p->on_allow_list);
+			}
+			else
+			{
+				sendto_one_numeric(source_p, ERR_OWNMODE,
+						form_str(ERR_OWNMODE),
+						target_p->name, "+g");
+				return;
+			}
+		}
+
 		/* reset idle time for message only if its not to self 
 		 * and its not a notice */
 		if(p_or_n != NOTICE)
 		sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
 				   target_p->name, target_p->user->away);
 
-	/*
-	 * XXX: Controversial? Allow target users to send replies through a +g.
-	 * Rationale is that people can presently use +g as a way to taunt users,
-	 * e.g. harass them and hide behind +g as a way of griefing.  --nenolod
-	 */
-	if(MyClient(source_p) && IsSetCallerId(source_p) && !accept_message(target_p, source_p))
-	{
-		rb_dlinkAddAlloc(target_p, &source_p->localClient->allow_list);
-		rb_dlinkAddAlloc(source_p, &target_p->on_allow_list);
-	}
-
 	if(MyClient(target_p))
 	{
 		if (IsSetNoCTCP(target_p) && p_or_n != NOTICE && *text == '\001' && strncasecmp(text + 1, "ACTION", 6))
 /* 491 ERR_NOOPERHOST, */       ":No appropriate operator blocks were found for your host",
 /* 492 ERR_NOCTCP */		":Can't send CTCP to %s (+C set)",
 /* 493 */       NULL,
-/* 494 */       NULL,
+/* 494 ERR_OWNMODE, */          "%s :cannot answer you while you are %s, your message was not sent",
 /* 495 ERR_KICKNOREJOIN */       ":%s 495 %s %s :Cannot rejoin channel so soon after being kicked (+J set)",
 /* 496 */       NULL,
 /* 497 */       NULL,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.