From fee59b1dd71182f00aadc65f1ed8651ee88f4571 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 4 Jun 2019 05:02:08 +0000
Subject: [PATCH] Add support for a "default sub-board" avatar (sub_default) in
 the [avatars] section of modopts.ini (the value is base64-encoded avatar
 data). If the <sub_code>_default or <group_name>_default keys exist, those
 defaults will be used as appropriate (both <sub_code> and <group_name> are
 lower-case). The avatar options ([avatars] section) of modopts.ini is cached
 (in bbs.mods) for performance reasons, so changes require a log-off/on to
 see.

---
 exec/showmsgavatar.js | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/exec/showmsgavatar.js b/exec/showmsgavatar.js
index ab73c1c3ee..0212b368c9 100644
--- a/exec/showmsgavatar.js
+++ b/exec/showmsgavatar.js
@@ -13,11 +13,32 @@
 require("smbdefs.js", 'MSG_ANONYMOUS');
 require("userdefs.js", 'USER_ANSI');
 
+function draw_default_avatar(sub)
+{
+	var options = bbs.mods.avatars_options;
+	if(!options) {
+		options = load({}, "modopts.js", "avatars");
+		if(!options)
+			options = { cached: true };
+		bbs.mods.avatars_options = options;	// cache the options
+	}
+	var avatar = options[sub + "_default"];
+	if(!avatar)
+		avatar = options[msg_area.sub[sub].grp_name.toLowerCase() + "_default"];
+	if(!avatar)
+		avatar = options.sub_default;
+	if(avatar)
+		Avatar.draw_bin(avatar, /* above: */true, /* right-justified: */true, bbs.msghdr_top_of_screen);
+}
+
 // Avatar support here:
 if(!(bbs.msg_attr&MSG_ANONYMOUS) 
 	&& (console.term_supports()&(USER_ANSI|USER_NO_EXASCII)) == USER_ANSI) {
 	var Avatar = load({}, 'avatar_lib.js');
-	Avatar.draw(bbs.msg_from_ext, bbs.msg_from, bbs.msg_from_net, /* above: */true, /* right-justified: */true
+	var success = Avatar.draw(bbs.msg_from_ext, bbs.msg_from, bbs.msg_from_net, /* above: */true, /* right-justified: */true
 		,bbs.msghdr_top_of_screen);
+	if(!success) {
+		draw_default_avatar(bbs.smb_sub_code);
+	}
 	console.attributes = 7;	// Clear the background attribute as the next line might scroll, filling with BG attribute
 }
-- 
GitLab