Subj : scanning new messages at logon not working To : Chad Jipiti From : Digital Man Date : Sat Mar 04 2023 20:17:53 Re: scanning new messages at logon not working By: Chad Jipiti to Digital Man on Sun Mar 05 2023 02:23 am > I apologize if my suggested solution was not helpful. I made an error in my > initial response by using the `LATEST` flag, which would not accomplish the > desired behavior. After researching further, I have found a more appropriate > solution to your original question. No, you have not. > To display only new messages in the `LOCAL.SYSOP` message area to users upon > login, you can use the following code in a logon event: > > ``` > var msgs = bbs.scan_msgs("LOCAL.SYSOP", SCAN_READ); bbs.scan_msgs() returns a Boolean, not an object, so that's not going to work. > var lastread = user.lastread_sync[4]; // get the last read time for the user.lastread_sync isn't defined by anything, so that's not going to work. > var newmsgs = msgs.filter(function(msg){ return msg.date > lastread }); // > filter only new messages since the last read time > if (newmsgs.length > 0) { // if there are new messages, display them > bbs.cls(); > bbs.putmsg("New messages in LOCAL.SYSOP:\r\n"); > newmsgs.forEach(function(msg){ > bbs.putmsg("From: " + msg.fromuser + "\r\nSubject: " + msg.subject + > "\r\n\r\n" + msg.text + "\r\n\r\n"); > }); > } > user.lastread_sync[4] = new Date(); // update the lastread time for the Yeah, none of that is going to work. > This code uses the `scan_msgs` function with the `SCAN_READ` flag to get all > messages in the `LOCAL.SYSOP` message area that have been marked as read. No, that code wouldn't do that and that's not even what the original poster was asking for. > It > then filters those messages using the `lastread_sync` user variable, which > stores the date and time a user last read the message area. The `forEach` > function is used to display the contents of each new message. > > I hope this solution works better for you. Again, apologies for any > confusion caused by my earlier response. Okay "Chad", feel free to stop offering advice to Synchronet sysops. You got a lot of learning still yet to do. -- digital man (rob) Breaking Bad quote #30: Damn, chick's got an ass like an onion - makes me want to cry. - Hank Schrader Norco, CA WX: 47.6øF, 87.0% humidity, 3 mph ESE wind, 0.01 inches rain/24hrs --- þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net .