-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathddoc2.js
955 lines (868 loc) · 29.7 KB
/
ddoc2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
/* rudimentary DOC interface; utilizing OO implementation nao */
/*
* ddoc2.js
*
* by: Damon Getsman
* contributing/refactoring also by: @Ntwitch (github.com)
* started: 18aug14
* alpha phase: 25oct14
* beta phase: 2aug15
* finished:
*
* a slightly more organized attempt to emulate the DOC shell from
* within Synchronet's SSJS libraries and functionality
*/
//includes
load("load/dmbase.js");
load("load/dmail.js");
load("load/dpoast.js");
load("load/dexpress.js");
load("load/dperuser.js");
load("load/dperroom.js");
//other includes
load("/sbbs/exec/load/sbbsdefs.js");
load("/sbbs/exec/load/nodedefs.js");
//pseudo-globals
const excuse = "\n\nThe rothe strikes! You die!. . .\n\n",
debugOnly = false, topebaseno = 6,
alwaysLogout = true, std_logging = true, maxMsgs = 500;
//a few easier hooks for the ctrl-a codes
const ctrl_a = "\1";
const green = ctrl_a + "g", yellow = ctrl_a + "y", blue = ctrl_a + "b",
white = ctrl_a + "w", red = ctrl_a + "r", cyan = ctrl_a + "c",
magenta = ctrl_a + "m", high_intensity = ctrl_a + "h",
normal = ctrl_a + "n";
const debugFields = ["flow_control", "message_posting", "message_scan",
"instant_messaging", "navigation", "file_io", "misc"];
const readlnMax = 1536;
const maxnodes = 10;
var stillAlive = true; //ask for advice on the 'right' way to do this
userSettings = null; roomSettings = { }; zappedRooms = null;
/*
* summary:
* Top level object for globals and primary program control flow/menu
*/
docIface = {
//top level menu
/*
* summary:
* Top-level menu contained within a string
*/
menu : green + high_intensity +
//$ctrl_a + "g" + "\n" + "<A>\tSysop commands\n" +
"\n\n<B>\tChange eXpress beeps\n<b>\tRead forum backward\n" +
"<C>\tConfig menu\n<D>\tchange Doing field\n" +
"<^E>\tEnter message with header\n<e>\tenter message normally" +
"\n<E>\tenter (upload)\n<f>\tread forum forward\n" +
"<F>\tshow Fortune\n<G>\tGoto next room\n" +
"<Q>\tAsk a question of a guide\n<i>\tforum information\n" +
"<I>\tchange forum information\n" +
"<j>\tjump to a room name/number\n<k>\tknown rooms list\n" +
"<l>\tlogout\n<N>\tselect new shell\n" +
"<n>\tread new msgs\n<o>\tread old msgs reverse" +
"\n<p>\tprofile user\n<P>\tprofile user (full info)\n" +
"<s>\tskip room\n<S>\tskip to\n<t>\tCurrent time\n" +
"<u>\tungoto last room\n<v>\texpress -1\n<w>\tWho's online?\n" +
"<W>\tshort wholist\n<x>\tsend eXpress message\n" +
"<X>\ttoggle eXpress status\n<^X>\tcheck old X messages\n" +
"<y>\tyell\n<z>\tzaproom\n<0-9>\tquickX\n<#>\tRead room by " +
"number\n<->\tread last n messages\n<%>\ttoggle guideflag " +
"status\n<@>\taidelist\n<\">\tquote Xes to Sysop\n" +
"<$>\tchange debugging settings\n\n",
/*
* summary:
* Save text prompt
*/
sprompt : high_intensity + yellow + "<A>" + green + "bort " +
yellow + "<C>" + green + "ontinue " + yellow + "<P>" +
green + "rint " + yellow + "<S>" + green + "ave " + yellow +
"<X>" + green + "press -> ",
// ----++++****====menu methods====****++++----
/*
* summary:
* pseudo-global level method exists in order to reduce redundant code by
* creating one global level method for exception throwing
* setname:
* the exception name to be given
* setmsg:
* the exception message
* setnum:
* exception number
*/
dDocException : function(setname, setmsg, setnum) {
this.name = setname;
this.message = setmsg;
this.number = setnum;
this.toString = function () {
return this.name + ": " + this.message + "\t#: " + this.number;
};
},
/*
* summary:
* Method is utilized to set the BBS status correctly for
* the node at whatever applicable point
* nodeAction:
* Found in nodedefs.js, the correct flag to set for where
* we are at right now
*/
setNodeAction : function(nodeAction) {
//set the node status
if (userSettings.debug.misc) {
console.putmsg(red + "Using node #: " + bbs.node_num + "\n");
}
bbs.node_action = nodeAction;
system.node_list[bbs.node_num - 1].action = bbs.node_action;
},
/*
* summary:
* Just a wrapper for console.getkey() at this point. This is utilized for
* any prompting situation where we want to be able to make sure that we're
* going to receive any X messages (or telegrams/messages or other inter-
* node communication) while the prompt is waiting for something from the
* user
* return:
* Unmodified return value from console.getkey()
*/
getChoice : function() {
var cmd = "";
this.setNodeAction(NODE_MAIN);
do {
bbs.nodesync(); //check for xpress messages
cmd = console.inkey(K_NOECHO, 1000);
} while (cmd == "");
bbs.log_key(cmd);
return cmd;
},
/*
* summary:
* Just to avoid duplicating too much code when logging needs to
* be done for both a string and a keystroke afterwards
* str:
* String value
* key:
* Character value
*
* NOTE: This might be broken in some areas; as I was doing the documentation
* pass I decided to change this one to throw an exception on error and
* ditch the return codes since it was so rudimentary
*/
log_str_n_char : function(str, key) {
try {
bbs.log_str(str);
bbs.log_key(key);
} catch (e) {
system.log("TTBBS Error " + e.description +
" when trying to save str+key to log");
throw new dDocException("log_str_n_char() Error", e.message, 1);
}
},
/*
* summary:
* Wrapper to handle logging along with node status changes, since they're
* bound to go together pretty often
* c:
* Character value to log (keylog)
* str:
* String to log to the logfile
* na:
* Bitfield for node action status (sbbsdefs.js)
*/
logStatusChange : function(c, str, na) {
try {
this.log_str_n_char(str, c);
this.setNodeAction(na);
} catch (e) {
var errmsg = "Problems with logStatusChange(): " + e.description +
"\nName: " + e.name + "\t\tMsg: " + e.message + "\n";
js.report_error(errmsg);
if (userSettings.debug.misc) {
console.putmsg(yellow + errmsg);
}
}
},
/*
* summary:
* Simply displays the docIface top level property 'menu'
* NOTE:
* See the commented out area where things need to be fixed in order to
* implement pausing (I think that's what it was working with, anyway)
*/
doMainMenu : function() {
bbs.log_key("?");
//we need to implement paging here
var brokenMenu = this.menu.split("\n");
if (userSettings.debug.misc) {
console.putmsg(red + "console.getlines(): " +
console.getlines() + "\tbrokenMenu.length: " +
brokenMenu.length + "\n");
}
for (var linecount = 0; linecount < brokenMenu.length; linecount++) {
/* if (Number.isInteger(linecount % (console.getlines() - 2))) {
console.putmsg(green + "--" + high_intensity +
"more" + normal + green + "--");
console.getkey();
console.putmsg("\n");
} THIS NEEDS TO BE FIXED */
console.putmsg(green + high_intensity + brokenMenu[linecount] +
"\n");
}
},
//sub-objects
nav : {
/*
* summary:
* Properly sets the bbs. and user. cursub/curgrp for a given
* room.
* room:
* The msg_area.grp_list[].sub_list[] element of the room to jump
* to
* return:
* String of the human-readable sub name.
*/
setSub : function(room) {
if (room === null) {
throw new dDocException("setSub() error", "Passed null room", 1);
}
if (room != "Mail") {
bbs.curgrp = room.grp_number;
bbs.cursub = room.index;
user.cursub = bbs.cursub_code;
return room.name;
} else {
return "Mail";
}
},
/*
* summary:
* Scans through known rooms (not zapped) starting from
* the current room and looks for new messages. If new messages
* are found, call setSub to point the user at the room.
* return:
* sub-board object if new messages were found
* null if no new messages were found
*/
findNew : function() {
var subList = msg_area.grp_list[bbs.curgrp].sub_list;
var ndx = subList[bbs.cursub].index;
var mBase;
if (userSettings.debug.message_scan) {
console.putmsg(yellow + "Entering findNew()\nWorking with subList" +
" of length " + subList.length + "; contents:\n");
for each(var tmpSub in subList) {
console.putmsg("* " + cyan + tmpSub.name + "\n");
}
console.putmsg("\n");
}
for ( /* ndx already set */ ; ndx < subList.length ; ndx += 1 ) {
if (userSettings.debug.navigation) {
console.putmsg(yellow + ndx + ": " +
roomData.tieIns.isZapped(ndx) + "\n");
}
if (!roomData.tieIns.isZapped(ndx)) {
mBase = msg_base.util.openNewMBase(subList[ndx].code);
if (userSettings.debug.navigation) {
console.putmsg("Room not zapped\t\tscan_ptr: " +
subList[ndx].scan_ptr + "\t\ttotal: " +
mBase.total_msgs + "\n");
}
if (mBase == null) {
break;
}
if (subList[ndx].scan_ptr < (mBase.total_msgs - 1)) {
docIface.nav.setSub(subList[ndx]);
mBase.close();
return subList[ndx];
} else if (subList[ndx].scan_ptr > (mBase.total_msg - 1)) {
//we've got some corrupt shit to fix here; not sure how it
//happened but we might as well have a way to fix it
//maybe checking for validity?
subList[ndx].scan_ptr = mBase.first_msg;
if (userSettings.debug.navigation) {
console.putmsg(yellow + " just fixed scan ptrs\n");
}
}
mBase.close();
}
}
// No new messages, reset to first room
docIface.nav.setSub(subList[0]);
return subList[ndx];
},
/*
* summary:
* Displays the prompt for a string to search for in the
* available message sub-boards, executes a call to the
* functionality to search for it and find it, and jumps to
* it, if available (via yet another call)
*/
jump : function() {
var uChoice, ouah;
console.putmsg(red + "Entered right code\n");
if (userSettings.debug.navigation) {
console.putmsg(green + "Entered jump()\n");
}
console.putmsg(green + high_intensity + "Jump to forum " +
"name? -> ");
uChoice = console.getstr().toUpperCase();
if (uChoice == "MAIL") {
if (userSettings.debug.navigation) {
console.putmsg("Entering Mail> code\n");
}
docIface.logStatusChange("j", "Jumped to Mail>", NODE_RMAL);
try {
uMail.readMail();
} catch (e) {
/*
* oh we've got a hell of a lot more than just this to worry about
* now
* if (userSettings.debug.navigation) {
console.putmsg(red + "Logout requested from Mail> code\n");
}
*/
if (userSettings.debug.message_scan) {
console.putmsg(red + "\nException:\t" + high_intensity +
e.name + "\n" + normal + magenta + e.message + "\n");
}
docIface.util.quitDdoc();
}
ouah = "Mail"; //vestigial?
} else if (uChoice == "") {
//abort
console.putmsg(yellow + "Aborted jump to new room . . .\n");
return;
} else {
try {
ouah = this.chk4Room(uChoice);
} catch (e) {
if (e.number == 1) {
console.putmsg(red + "No list returned\n");
} else {
console.putmsg(red + high_intensity + "Room not found");
}
return;
}
if (userSettings.debug.navigation) {
console.putmsg("Got back " + ouah.name + " from chk4Room\n");
console.putmsg(yellow + "Zapped contains: " +
zappedRooms[user.number].zRooms + "\n");
}
}
if (ouah.code.toUpperCase() != "MAIL") {
docIface.logStatusChange("j", "Jumped to " + this.setSub(ouah) +
">", NODE_RMSG);
if (userSettings.debug.navigation) {
console.putmsg(cyan + "Set sub/tmpBase to " + ouah.code + "\n");
}
var tmpBase = new MsgBase(ouah.code);
/*if (!tmpBase.is_open) {
try {
tmpBase.open();
} catch (e) {
console.putmsg(red + e.message + "\n");
}
}*/
tmpBase = msg_base.util.openNewMBase(ouah.code);
if (userSettings.debug.navigation) {
console.putmsg(blue + high_intensity + "tmpBase is open: " +
tmpBase.is_open + "\n");
console.putmsg(yellow + "Testing for subnum: " + tmpBase.subnum +
"\t(File: " + tmpBase.file + ")\n");
}
if (roomData.tieIns.isZapped(tmpBase.cfg.index)) {
//we're working with a zapped room
if (userSettings.debug.navigation) {
console.putmsg(yellow + "Rooms zapped: " +
zappedRooms[user.number].zRooms + "\nUnzapping " +
tmpBase.cfg.index + "\n");
}
roomData.tieIns.unzapRoom(tmpBase.cfg.index);
if (userSettings.debug.navigation) {
console.putmsg(yellow + "Rooms zapped: " +
zappedRooms[user.number].zRooms + "\n");
}
}
}
return;
},
/*
* summary:
* Mark all messages as read in the current room and
* call findNew() to change to the next room with unread messages
* NOTE:
* skip() should _NOT_ mark all messages in the current room as
* read; it should just skip to the next room in the list
*/
skip: function () {
// use findNew to change to next room with unread messages
bbs.log_key("s");
this.findNew();
},
/*
* summary:
* Searches for the substring within the list of available
* sub-boards
* srchStr:
* Substring to search for
* return:
* The object for the sub-board if a match, exceptions are thrown
* on appropriate error conditions
*/
chk4Room : function (srchStr) {
var rList = docIface.util.getRoomList(true);
if (rList == null) {
throw new dDocException("chk4Room() exception",
"Roomlist is null", 1);
}
for each (var rm in rList) {
if (rm.description.toUpperCase().indexOf(
srchStr.toUpperCase()) != -1) {
if (userSettings.debug.misc) {
console.putmsg("Success in chk4Room()\n");
}
return rm;
}
}
//bad failover method, but whatever
throw new dDocException("chk4Room() exception", "No match", 2);
}
},
//sub-object
util : {
// --++==**properties**==++--
preSubBoard : null,
preFileDir : null,
preMsgGroup : null,
/*
* summary:
* Returns an array of message rooms that are
* accessible; this will be extended as functionality for
* not being confined is expanded. Also, this may be
* useful in the future for listKnown() and other routines
* in dmbase.js that are recreating the wheel a bit
* return:
* As I redundantly and out-of-proper-orderly mentioned
* above, it returns an array of sub-board objects
* If running non-confined, returns null. When this feature is
* finally ready to be implemented, it might be necessary to return
* some sort of JSON or list of arrays in order to handle the
* deeper data structure than we're currently utilizing
*/
getRoomList : function(/*in the future, group here too*/) {
//var debugging = true;
if (userSettings.confined) {
//damn we don't need anything complex, durrr
if (userSettings.debug.misc) {
console.putmsg(red + "Working with sub list: " +
msg_area.grp_list[topebaseno].sub_list.toString() +
"\n");
}
return msg_area.grp_list[topebaseno].sub_list;
} else {
return null; //ereh
}
},
/*
* summary:
* Saves the settings that we want to restore upon exit from the
* ddoc shell; not sure if this is going to work properly due to
* JavaScript scope, this is kind of pushing the limits of what
* I know off the top of my head. This could also be stored to
* a scratchpad in the $SBBSHOME/user/ directory, as well.
*/
initDdoc : function() {
bbs.log_str("Initializing dDoc session");
//load user settings
userSettings = userRecords.defaultSettings(user.number);
try {
userSettings = userRecords.userDataIO.loadSettings(user.number);
} catch (e) {
console.putmsg(red + high_intensity +
"Loading userSettings in initDdoc:\n");
console.putmsg(red + e.toString() + "\n");
}
//load room settings -- WHAT THE FUCK IS GOING ON WITH THE NESTED TRY/
//CATCH BULLSHIT HERE? Vestigial horror no doubt; fix this
//try {
try {
roomData.fileIO.snagRoomInfoBlob();
} catch (e) {
if (userSettings.debug.file_io) {
console.putmsg(cyan + "Exception reading default room info\n"
+ "Message: " + e.message + "\tNum: " + e.number + "\n");
}
}
/*} catch (e) {
console.putmsg(red + high_intensity + "Loading room data in " +
"initDdoc:\n");
console.putmsg(red + e.message + "\n");
}*/
if (userSettings.debug.misc) {
userRecords.userDataUI.displayDebugFlags(user.number);
console.putmsg("Turning off Synchronet defaults for dDoc\n");
}
//save user setting defaults
this.preUserSettings = user.settings;
this.turnOffSynchronetDefaults();
if (userSettings.confined) {
bbs.log_str(user.alias + " is entering dDOC shell and " +
"confined to " + msg_area.grp_list[topebaseno].name +
" group");
} else {
bbs.log_str(user.alias + " entering dDOC shell");
}
//set node status here, maybe?
//then again beware the fact that this bitwise shit can really be what
//is fucking with shit on other nodes and everything. the 'orrah
docIface.setNodeAction(NODE_MAIN);
//turn on asynchronous message arrival
bbs.sys_status &=~ SS_MOFF;
//turn off time limit
user.security.exemptions |= UFLAG_H;
//this is how it SHOULD work, anyway
//turn on user pauses
user.settings |= USER_PAUSE;
//save bbs defaults
if (userSettings.debug.misc) {
console.putmsg(yellow + "Saving settings for later restoration:\n" +
"preSubBoard (user.cursub):\t" + green + user.cursub + yellow +
"\npreMsgGroup (user.curgrp):\t" + green + user.curgrp + yellow +
"\npreFileDir (user.curdir):\t" + green + user.curdir + "\n");
}
this.preSubBoard = user.cursub;
this.preMsgGroup = user.curgrp;
this.preFileDir = user.curdir;
//snag user zapped rooms list
try {
roomData.fileIO.snagUserZappedRooms();
} catch (e) {
console.putmsg(red + "Not sure what happened in " +
"snagUserZappedRooms()\nExc:\t" + e.name + "\nMsg:\t" + e.message
+ "\nNumber:\t " + e.number + "\n");
}
if (userSettings.confined) {
if (userSettings.debug.flow_control) {
console.putmsg("Moving user to " +
msg_area.grp_list[topebaseno].name + ":" +
msg_area.grp_list[topebaseno].sub_list[0].name + "\n");
}
docIface.nav.setSub(msg_area.grp_list[topebaseno].sub_list[0]);
}
},
/*
* summary:
* method exists solely to turn off defaults from synchronet that
* are unwanted in the dDoc interface
*/
turnOffSynchronetDefaults : function() {
//turn off scans THIS IS PROBABLY WHERE BITWISE SHIT IS FUCKED UP, OR AT
//LEAST A PART OF IT
user.settings &= ~USER_ASK_NSCAN;
user.settings &= ~USER_ASK_SSCAN;
user.settings &= ~USER_ANFSCAN;
/*
* NOTE: These should be saved and turned back on afterwards; this
* will probably fix the issue with timeouts or at least some of the
* aberrant behavior that happens when one drops from this shell back
* out to the synchronet default when not logging in with it
*/
},
/*
* summary:
* Restores settings that were detected at first going into
* ddoc, in order to restore functionality to where it was
* left off for somebody that may be jumping between
* shells, or the like. As mentioned above; this may be
* out of scope and needing a better solution. For some reason
* this also refuses to work properly when not called from the
* lowest-level primary menu; not sure what's up with that, Digital
* Man just referred me to logout.c or something and I couldn't
* make heads or tails of it just yet
*/
quitDdoc : function() {
docIface.logStatusChange("l", user.alias + " is leaving dDoc",
NODE_LAST_ACTION);
/* bbs.log_str(user.alias + " is leaving dDOC shell");
bbs.log_key("L"); */
if (userSettings.debug.flow_control) {
console.putmsg(red + "\nRestoring user.* properties:\n" +
" user.cursub: " + this.preSubBoard + "\n" +
" user.curgrp: " + this.preMsgGroup + "\n" +
" user.curdir: " + this.preFileDir + "\n");
console.putmsg(red + "\nRestoring user.settings . . .\n");
}
//restore initial settings prior to exit MORE BITWISE DEBAUCHERY
user.cursub = this.preSubBoard;
//user.cursub = bbs.cursub_code;
user.curgrp = this.preMsgGroup;
user.curdir = this.preFileDir;
user.settings = this.preUserSettings;
//disable H exemption in case they go back to usual shell so that
//we can handle events, etc
user.security.exemptions &= ~UFLAG_H;
//restore asynchronous message status (if necessary)
bbs.sys_status ^= SS_MOFF;
console.putmsg(blue + high_intensity + "\n\nHope to see you " +
"again soon!\n\nPeace out!\n");
bbs.logout();
},
/*
* summary:
* Searches the correct file in /sbbs/user for the proper
* block of information regarding the current sub/room and
* displays that information with proper DOC-ish heading
* information.
* NOTE:
* I believe this is completely vestigial at this point; need to
* run through and verify before removing it. This should all be
* handled from within dperroom's code right now, though.
*/
dispRoomInfo : function() {
bbs.log_key("i");
if (userSettings.debug.misc) {
console.putmsg(red + "Entered 'i'nfo (dispRoomInfo()) in " +
"docIface.util\n");
}
//take care of the header
console.putmsg(green + high_intensity + "Forum Info\n\nForum " +
"moderator is " + cyan + "<not implemented> " + green +
" Total messages: " + red + "<not implemented>\n" +
green + "Forum info last updated: " + magenta +
"<not implemented> " + green + "by " + cyan +
"<not implemented>\n\n");
}
}
}
// ---+++***===Execution Begins===***+++---
var preSubBoard, preFileDir, preMsgGrp, preUserSettings;
var uchoice;
//save initial conditions
docIface.util.initDdoc();
/*
* changing this to user.curgrp isn't going to work as the user object
* has no curgrp. need to find out if bbs.curgrp is going to work, and
* if not, how do we reverse lookup a group from a sub code name
*/
if (userSettings.confined && (bbs.curgrp != topebaseno) &&
userSettings.debug.flow_control) {
//are we already in a dystopian area?
console.putmsg(red + "CurGrp: " + bbs.curgrp + normal + "\n" +
"Trying a jump . . .\n");
bbs.curgrp = topebaseno;
} else if (userSettings.confined && (bbs.curgrp != topebaseno)) {
bbs.curgrp = topebaseno;
}
if (!debugOnly) {
/* the main program loop */
while (stillAlive) {
if (userSettings.debug.flow_control) {
console.putmsg("Got " + user.cursub + " in user.cursub\n");
}
//dynamic prompt
dprompt = yellow + high_intensity + msg_area.sub[user.cursub].name +
"> ";
//maintenance
bbs.main_cmds++;
//check for async messages waiting
bbs.nodesync();
console.putmsg("\n" + dprompt);
uchoice = docIface.getChoice();
switch (uchoice) {
//top menu
case '?':
docIface.doMainMenu();
break;
//message base entry commands
case ' ':
uchoice = 'n';
case 'b':
case 'e':
case 'E':
case 'r':
case 'n':
case 'o':
case 'k':
case '-':
case '%':
msg_base.entry_level.handler(uchoice);
break;
//other msg base shit
case 'j':
//jump to new sub-board (room in DOCspeak)
try {
docIface.nav.jump();
} catch (e) {
console.putmsg(red + "Error in jump()\n" + e.message +
"\t#: " + e.number + "\n");
}
//is this room zapped?
if (userSettings.debug.navigation) {
console.putmsg(yellow + "Testing for zapped status on" +
" room no: " + bbs.cursub + "\n");
}
if (roomData.tieIns.isZapped(bbs.cursub)) {
if (userSettings.debug.navigation) {
console.putmsg(red + "zRooms contents: " +
zappedRooms[user.number].zRooms + "\n");
console.putmsg(yellow + "Attempting to unZap() " +
bbs.cursub + "\n");
}
//unzap it
roomData.tieIns.unzapRoom(bbs.cursub);
if (userSettings.debug.navigation) {
console.putmsg(red + "zRooms contents: " +
zappedRooms[user.number].zRooms + "\n");
}
}
break;
//logout
case 'l':
console.putmsg(yellow + high_intensity + "Logout: \n");
if (!console.noyes("Are you sure? ")) {
docIface.util.quitDdoc();
stillAlive = false;
} else {
console.putmsg(green + high_intensity +
"Good choice. ;)\n");
}
break;
case 'w':
wholist.list_long(wholist.populate());
break;
case 'x':
express.sendX();
break;
case 'W':
wholist.list_short(wholist.populate());
break;
case 'y':
poast.yell();
break;
case 'N':
bbs.select_shell();
/*
* please note that after my torpor finishes and I get
* back on this tomorrow that this also requires a call
* to resetting the defaults/logout procedure for dDOC,
* and then finally (perhaps alternate way to dump the
* active shell) and then to respawn the user's newly
* selected shell; talk to the dues on Synchronet IRC
* about the best way to handle this or look in the
* classic shell code
*/
docIface.util.quitDdoc();
stillAlive = false;
break;
case 's':
console.putmsg(green + high_intensity + "Skip room\n");
docIface.nav.skip();
break;
case 'c':
userConfig.reConfigure();
break;
case 'D':
console.putmsg(green + high_intensity + "Change doing field\n");
userSettings.doing = userRecords.userDataUI.getDoing();
try {
userRecords.userDataIO.saveSettings(user.number,
userSettings);
// next line will not execute if there is an exception
// while saving
console.putmsg(green + high_intensity + "Doing field " +
"updated.\n\n");
} catch (e) {
console.putmsg(red + "Exception saving settings: "
+ e.toString() + "\n");
}
break;
case 'i': //display room info
roomData.roomSettingsUX.displayRoomInfo();
break;
case 'I': //change room info (if applicable)
roomData.roomSettingsUX.promptUserForRoomInfo();
break;
case 'z': //zap room
if (console.yesno("Are you sure you want to forget this " +
"forum? ")) {
this.log_str_n_char("z", "Trying to forget " +
bbs.cursub_code);
roomData.tieIns.zapRoom(bbs.cursub);
}
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': //we're going to read message by number here
//there will, of course, have to be some error checking for
//trying to hit out of bounds messages if dispMsg() doesn't
//already have it; which I forgot for a long time, of course,
//and now is resulting in the bug that I'm trying to fix
try {
msg_base.entry_level.gotoMessageByNum(uchoice);
} catch (e) {
console.putmsg(red + "Caught:\n" + high_intensity +
e.name + "\n" + e.message + "\n\n");
}
break;
case '$': //change debugging flags for this user
var dropOut = false;
var un;
docIface.logStatusChange("$", "Changing debugging flags",
NODE_DFLT);
if (user.security.level < 80) {
userRecords.userDataUI.queryDebugSettings(user.number);
} else {
console.putmsg(yellow + high_intensity + "User name to " +
"modify debug settings for: ");
un = bbs.finduser(console.getstr());
while (un < 1) {
console.putmsg(red + high_intensity + "User not " +
"found. Enter another username or \"DONE\" to " +
" escape.\nUsername: ");
un = console.getstr();
if (un == "DONE") {
dropOut = true;
} else {
un = bbs.finduser(un);
}
}
//we should have a valid # now or else be out of here :P
if (!dropOut) {
userRecords.userDataUI.queryDebugSettings(un);
}
}
break;
case 'p': //profile a user
var usr;
console.putmsg(green + high_intensity +
"User to profile -> ");
try {
userRecords.userDataUI.profileUser(usr = console.getstr());
docIface.log_str_n_char("p", "Profiled " + usr);
} catch (e) {
console.putmsg(red + "Problem profiling: " +
high_intensity + e.message + "\n");
}
break;
default:
console.putmsg(excuse);
break;
}
}
} else {
if (dMBTesting.init() != 0) {
console.putmsg(red + "\n\nFUCK\n\n" + normal);
} else {
console.putmsg(yellow + "\nCzech and see if it's where it " +
"should be theyah, budday\n\n" + normal);
}
}
console.putmsg(yellow + high_intensity + "\n\nGoodbye!\n");
if (alwaysLogout) {
bbs.logout();
}