From 40a47c302d2011b79b6875a636fc4e6b71a1e9a9 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows 11)" <rob@synchro.net>
Date: Sun, 10 Dec 2023 13:47:01 -0800
Subject: [PATCH] Add new @-codes: MSG_TO_FIRST and MSG_FROM_FIRST

The first word of the message recipient or author's name.

For Accession.
---
 src/sbbs3/atcodes.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/sbbs3/atcodes.cpp b/src/sbbs3/atcodes.cpp
index baf19409e3..f092eba73d 100644
--- a/src/sbbs3/atcodes.cpp
+++ b/src/sbbs3/atcodes.cpp
@@ -1863,6 +1863,14 @@ const char* sbbs_t::atcode(const char* sp, char* str, size_t maxlen, int* pmode,
 			*pmode |= (current_msg->hdr.auxattr & MSG_HFIELDS_UTF8);
 		return(current_msg_to);
 	}
+	if(!strcmp(sp,"MSG_TO_FIRST") && current_msg_to!=NULL) {
+		if(pmode != NULL && current_msg != NULL)
+			*pmode |= (current_msg->hdr.auxattr & MSG_HFIELDS_UTF8);
+		safe_snprintf(str, maxlen, "%s", current_msg_to);
+		if((tp = strchr(str, ' ')) != NULL)
+			*tp = '\0';
+		return str;
+	}
 	if(!strcmp(sp,"MSG_TO_EXT") && current_msg!=NULL) {
 		if(current_msg->to_ext==NULL)
 			return(nulstr);
@@ -1901,6 +1909,15 @@ const char* sbbs_t::atcode(const char* sp, char* str, size_t maxlen, int* pmode,
 			*pmode |= (current_msg->hdr.auxattr & MSG_HFIELDS_UTF8);
 		return(current_msg_from);
 	}
+	if(!strcmp(sp,"MSG_FROM_FIRST") && current_msg != NULL && current_msg_from != NULL) {
+		if(current_msg->hdr.attr&MSG_ANONYMOUS && !SYSOP)
+			safe_snprintf(str, maxlen, "%s", text[Anonymous]);
+		else
+			safe_snprintf(str, maxlen, "%s", current_msg_from);
+		if((tp = strchr(str, ' ')) != NULL)
+			*tp = '\0';
+		return str;
+	}
 	if(!strcmp(sp,"MSG_FROM_EXT") && current_msg!=NULL) {
 		if(!(current_msg->hdr.attr&MSG_ANONYMOUS) || SYSOP)
 			if(current_msg->from_ext!=NULL)
-- 
GitLab