Accessing Syncdata
From
Angus McLeod@VERT/ANJO to
Finnigann on Mon Aug 6 07:21:00 2007
Here's a fairly simple JS script you can try. Copy it to "junky.js" in
your EXEC directory, and from there you can run it by typing
jsexec junky
at a command prompt. Here is the script:
load("sbbsdefs.js"); // load some useful SBBS definitions
var sub = "hobbies"; // search this sub
var subj_search = new RegExp(/Fokker/i); // RE search
var want_body = false; // keep it short
// open the message base;
smb = new MsgBase(sub);
if ( smb.open != undefined && smb.open() == false) {
printf( "Uh-oh! Can't access %s: %s\r\n", sub, smb.last_error );
delete smb;
exit;
}
// process each message in message base
for (ptr = smb.first_msg;
ptr <= smb.last_msg && !js.terminated;
ptr++) {
// grab the header
header = smb.get_msg_header( false, ptr, false );
// skip certain messages for operational reasons
if (header == null) continue;
if (header.attr & MSG_DELETE) // skip marked for deletion
continue;
if (header.attr & MSG_MODERATED && !(hdr.attr&MSG_VALIDATED))
continue;
if (header.attr & MSG_PRIVATE) // skip private messages
continue;
if (header.reverse_path) // no dupe loop
continue;
if (header.from_net_type // don't gate
&& smb.cfg != undefined && !(smb.cfg.settings & SUB_GATE))
continue;
// skip messages that don't match subject-wise
if (!header.subject.match( subj_search )) continue;
// give some very basic header info
printf( "From: %s\nTo : %s\nSubj: %s\n\n",
header.from, header.to, header.subject );
// retrieve and message body if needed
if (want_body) {
body = smb.get_msg_body( false, ptr, true, true, true );
if (body == null) {
printf( "Uh-oh! Can't read body for #%ld\n", ptr);
continue;
}
print( body );
}
}
It searches the "hobbies" message-base for any message that mentions the
word "Fokker" in the subject, and lists a few fields (and the body, if you really want). It just lists on the console. You can redirect to disk.
It would be fairly straightforward to search according to a complex set of criteria, examining from/to, date, etc and even the body-text itself,
before deciding whether to dump the message or not.
Biggest problem with this is that it searches every message in the message base. *NOT* just the ones that have been added since the last time it
ran. You would have to store smb.last_msg in a file somewhere on disk and read it back for use as a starting point instead of using smb.first_msg
wach time. Not hard, but not part of this simple example.
Now, would a more advanced version of this script be what you are looking
for? (A separate script could be written to add messages to a sub.)
And, with your knowledge of BATch programming, are you able to make any
sort of sense of this programming?
---
Playing loud: "Star" by "David Bowie"
from "The rise & fall of Ziggy Stardust & the spiders from Mars" album.
þ Synchronet þ Where we BAJA Rob into writing our modules. The ANJO BBS