home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 189.img / TCS120S.ZIP / CHATMOD.PAS < prev    next >
Pascal/Delphi Source File  |  1989-02-24  |  11KB  |  451 lines

  1. {$R-,S-,I-,D-,T-,F+,V-,B-,N-,L+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit chatstuf;
  5.  
  6. interface
  7.  
  8. uses crt,dos,
  9.      gentypes,gensubs,subs1,userret,flags,mainr1,modem,windows,statret,configrt;
  10.  
  11. function specialcommand:boolean;
  12. procedure specialseries;
  13. procedure chat (gotospecial:boolean);
  14.  
  15. implementation
  16.  
  17. function specialcommand:boolean;
  18.  
  19.   procedure getnewtime;
  20.   var q:sstr;
  21.       n:integer;
  22.   begin
  23.     n:=timeleft;
  24.     writeln (usr,'The user has ',n,' minutes left.');
  25.     write (usr,'New time left for today? ');
  26.     readline (q);
  27.     if length(q)>0 then begin
  28.       urec.timetoday:=urec.timetoday+(valu(q)-n);
  29.       writeurec;
  30.       writeln ('You have been granted ',timeleft,' minutes for today.')
  31.     end
  32.   end;
  33.  
  34.   procedure getnewlevel;
  35.   var q:sstr;
  36.       n:integer;
  37.   begin
  38.     writeln (usr,'Current level: ',ulvl);
  39.     write (usr,'New level [-1 to trash]: ');
  40.     readline (q);
  41.     if length (q)>0 then begin
  42.      n:=valu(q);
  43.      ulvl:=n;
  44.      urec.level:=n;
  45.      writeurec;
  46.      writeln ('You have been granted level ',n,' access.');
  47.      if n=-1 then writeln ('That means you''ve been thrown off this system.')
  48.     end
  49.   end;
  50.  
  51.   procedure getnewaccess;
  52.   var q,bname:sstr;
  53.       bn:integer;
  54.       ac:accesstype;
  55.       wasopen:boolean;
  56.       k:char;
  57.  
  58.     function inputaccess (q:sstr):accesstype;
  59.     begin
  60.       inputaccess:=invalid;
  61.       if length(q)=0 then exit;
  62.       case upcase(q[1]) of
  63.         'L':inputaccess:=letin;
  64.         'B':inputaccess:=bylevel;
  65.         'K':inputaccess:=keepout
  66.       end
  67.     end;
  68.  
  69.     procedure getallaccess;
  70.  
  71.       procedure setallaccess (ac:accesstype);
  72.       var cnt:integer;
  73.       begin
  74.         setalluserflags (urec,ac);
  75.         writeln ('Your access to all sub-boards: ',accessstr[ac]);
  76.         writeurec
  77.       end;
  78.  
  79.     begin
  80.       write (usr,'Grant ALL access ([B]y level, [L]et in, [K]eep out, or CR): ');
  81.       readline (q);
  82.       ac:=inputaccess(q);
  83.       if ac<>invalid then setallaccess(ac)
  84.     end;
  85.  
  86.   var bd:boardrec;
  87.   begin
  88.     write (usr,'Which board for which to change access [*=all]: ');
  89.     readline (bname);
  90.     if length(bname)=0 then exit;
  91.     if bname='*' then
  92.       begin
  93.         getallaccess;
  94.         exit
  95.       end;
  96.     opentempbdfile;
  97.     bn:=searchboard(bname);
  98.     if bn=-1 then
  99.       begin
  100.         closetempbdfile;
  101.         writeln (usr,'No such board!  Press any key..');
  102.         k:=bioskey;
  103.         exit
  104.       end;
  105.     writeln (usr,'Board ',bname,'... Current access: ',
  106.       accessstr[getuseraccflag(urec,bn)]);
  107.     write (usr,'Grant access ([B]y level, [L]et in, [K]eep out, or CR: ');
  108.     readline (q);
  109.     ac:=inputaccess(q);
  110.     if ac=invalid then begin
  111.       closetempbdfile;
  112.       exit
  113.     end;
  114.     setuseraccflag (urec,bn,ac);
  115.     writeurec;
  116.     closetempbdfile;
  117.     writeln ('New access for board ',bname,': ',accessstr[ac])
  118.   end;
  119.  
  120.   procedure hangupyn;
  121.   var q:sstr;
  122.   begin
  123.     write (usr,'Hang up on him (Y/N)? ');
  124.     readline (q);
  125.     if length(q)>0 then if upcase(q[1])='Y' then
  126.       begin
  127.         writeln ('*** System going down ***    '^M^M);
  128.         hangup;
  129.         forcehangup:=true;
  130.         specialcommand:=true
  131.       end
  132.   end;
  133.  
  134.   procedure getnewname;
  135.   var m:mstr;
  136.       n:integer;
  137.       t:string[1];
  138.   begin
  139.     writeln (usr,'Current name: ',unam);
  140.     write (usr,'New name: ');
  141.     readline (m);
  142.     if length(m)<>0 then begin
  143.       if not validuname(m) then begin
  144.         writeln (usr,'Invalid name!');
  145.         exit
  146.       end;
  147.       n:=lookupuser(m);
  148.       if n<>0 then begin
  149.         write (usr,'Name already exists!  Are you sure? ');
  150.         buflen:=1;
  151.         readline (t);
  152.         if upcase(t[1])<>'Y' then exit
  153.       end;
  154.       unam:=m;
  155.       urec.handle:=m;
  156.       writeurec;
  157.       writeln ('Your name is changed to ',unam,'.')
  158.     end
  159.   end;
  160.  
  161.   procedure getnewpassword;
  162.   var m:mstr;
  163.   begin
  164.     writeln (usr,'Current password: ',urec.password);
  165.     write (usr,'New password: ');
  166.     readline (m);
  167.     if length(m)<>0 then begin
  168.       urec.password:=m;
  169.       writeurec;
  170.       writeln ('Your password has been changed.')
  171.     end
  172.   end;
  173.  
  174.   procedure getnewud;
  175.   var m:mstr;
  176.  
  177.     procedure getnewud1 (var i:integer; q:sstr);
  178.     begin
  179.       if length(m)>1
  180.         then i:=valu(copy(m,2,255))
  181.         else begin
  182.           writeln (usr,'New file transfer '+q+'? ');
  183.           readline (m);
  184.           if length(m)=0
  185.             then exit
  186.             else i:=valu(m)
  187.         end;
  188.       writeln ('New file transfer ',q,': ',i);
  189.       writeurec
  190.     end;
  191.  
  192.   begin
  193.     writeln (usr,'Current upload L)evel:  ',urec.udlevel);
  194.     writeln (usr,'Current upload P)oints: ',urec.udpoints);
  195.     write (usr,'Enter L, P, or CR for neither: ');
  196.     readline (m);
  197.     if length(m)>0 then begin
  198.       case upcase(m[1]) of
  199.         'L':getnewud1 (urec.udlevel,'level');
  200.         'P':getnewud1 (urec.udpoints,'points')
  201.       end
  202.     end
  203.   end;
  204.  
  205.   procedure snoopmode;
  206.   begin
  207.     writeln (usr,'All I/O to the modem is locked.');
  208.     modeminlock:=true;
  209.     setoutlock (true)
  210.   end;
  211.  
  212.   procedure unsnoop;
  213.   begin
  214.     writeln (usr,'I/O to the modem is re-enabled.');
  215.     modeminlock:=false;
  216.     setoutlock (false)
  217.   end;
  218.  
  219.   procedure gotodos;
  220.   begin
  221.     writeln ('The sysop has dropped into DOS; please wait...');
  222.     window (1,1,80,25);
  223.     gotoxy (1,25);
  224.     writeln (usr,^M^J^J^J);
  225.     updateuserstats (false);
  226.     writereturnbat;
  227.     ensureclosed;
  228.     halt (4)
  229.   end;
  230.  
  231.   procedure getsysopaccess;
  232.   const sysopstr:array [false..true] of string[6]=('Normal','Sysop');
  233.         sectionnames:array [udsysop..databasesysop] of string[20]=
  234.           ('File transfer','Bulletin section','Voting booths',
  235.            'E-mail section','Doors','Main menu','Databases');
  236.   var cnt:configtype;
  237.       x:string[10];
  238.       n,mx:integer;
  239.       v:boolean;
  240.   begin
  241.     repeat
  242.       clrscr;
  243.       mx:=1;
  244.       for cnt:=udsysop to databasesysop do begin
  245.         write (usr,mx:3,'. ',sectionnames[cnt]);
  246.         mx:=mx+1;
  247.         gotoxy (25,wherey);
  248.         writeln (usr,sysopstr[cnt in urec.config])
  249.       end;
  250.       write (usr,^M^J'Number to toggle [CR to exit]: ');
  251.       buflen:=1;
  252.       readline (x);
  253.       n:=valu(x);
  254.       v:=(n>0) and (n<mx);
  255.       if v then begin
  256.         cnt:=configtype(ord(udsysop)+n-1);
  257.         if cnt in urec.config
  258.           then
  259.             begin
  260.               urec.config:=urec.config-[cnt];
  261.               x:='denied'
  262.             end
  263.           else
  264.             begin
  265.               urec.config:=urec.config+[cnt];
  266.               x:='granted'
  267.             end;
  268.         writeln ('You have been ',x,' sysop priveleges for the ',
  269.                  sectionnames[cnt],'.')
  270.       end
  271.     until not v;
  272.     writeurec
  273.   end;
  274.  
  275. var scom:sstr;
  276.     k:char;
  277. begin
  278.   writeln (^B^M'One moment please...');
  279.   splitscreen (12);
  280.   top;
  281.   clrscr;
  282.   specialcommand:=false;
  283.   writeln (usr,'Special commands:');
  284.   writeln (usr,'N)ame, P)assword, L)evel, T)ime left, B)oard access, H)ang up, U)UD section,');
  285.   writeln (usr,'Y)Sysop access, S)noop, Z)unsnoop, D)OS, Q)uit');
  286.   write (usr,'---> ');
  287.   readline (scom);
  288.   clearbreak;
  289.   k:=' ';
  290.   if length(scom)>0 then begin
  291.     k:=upcase(scom[1]);
  292.     case k of
  293.       'L':getnewlevel;
  294.       'B':getnewaccess;
  295.       'H':hangupyn;
  296.       'N':getnewname;
  297.       'P':getnewpassword;
  298.       'L':getnewlevel;
  299.       'T':getnewtime;
  300.       'U':getnewud;
  301.       'S':snoopmode;
  302.       'Z':unsnoop;
  303.       'Y':getsysopaccess;
  304.       'D':gotodos;
  305.     end
  306.   end;
  307.   bottomline;
  308.   specialcommand:=k in ['Q','S','Z'];
  309.   unsplit
  310. end;
  311.  
  312. procedure specialseries;
  313. begin
  314.   repeat until specialcommand
  315. end;
  316.  
  317. procedure chat (gotospecial:boolean);
  318. var k:char;
  319.     cnt,displaywid:integer;
  320.     quit,carrierloss,fromkbd:boolean;
  321.     linebuffer:lstr;
  322.     l:byte absolute linebuffer;
  323.     curcolor:byte;
  324.     baudst,commst:mstr;
  325.  
  326.   procedure instruct;
  327.   begin
  328.     splitscreen (3);
  329.     top;
  330.     clrscr;
  331.     write (usr,'Now in chat mode.  Press <F1> to leave or <F2> for commands.');
  332.     bottom
  333.   end;
  334.  
  335.   procedure wordwrap;
  336.   var cnt,wl:integer;
  337.       ww:lstr;
  338.   begin
  339.     ww:='';
  340.     cnt:=displaywid;
  341.     while (cnt>0) and (linebuffer[cnt]<>' ') do cnt:=cnt-1;
  342.     if cnt=0 then ww:=k else begin
  343.       ww:=copy(linebuffer,cnt+1,255);
  344.       wl:=length(ww)-1;
  345.       if wl>0 then begin
  346.         for cnt:=1 to wl do write (^H);
  347.         for cnt:=1 to wl do write (' ')
  348.       end
  349.     end;
  350.     writeln;
  351.     ansicolor (curcolor);
  352.     write (ww);
  353.     linebuffer:=ww
  354.   end;
  355.  
  356.   procedure typedchar (k:char);
  357.   var ec:byte;
  358.   begin
  359.     l:=l+1;
  360.     linebuffer[l]:=k;
  361.     if fromkbd then ec:=urec.regularcolor else ec:=urec.inputcolor;
  362.     if curcolor<>ec then begin
  363.       curcolor:=ec;
  364.       ansicolor (curcolor)
  365.     end;
  366.     if l=displaywid then wordwrap else write(k)
  367.   end;
  368.  
  369. begin
  370.   carrierloss:=false;
  371.   chatmode:=false;
  372.   writeln (^B^M);
  373.   if wanted in urec.config then begin
  374.     specialmsg ('(No longer wanted)');
  375.     urec.config:=urec.config-[wanted];
  376.     writeurec;
  377.   end;
  378.   if eightycols in urec.config then displaywid:=80 else displaywid:=40;
  379.   if length(chatreason)>0 then specialmsg ('(Chat reason: '+chatreason+')');
  380.   chatreason:='';
  381.   if gotospecial then begin
  382.     specialseries;
  383.     exit
  384.   end;
  385.   clearbreak;
  386.   nobreak:=true;
  387.   writeln (^M^M,sysopname,' is here.'^M);
  388. { added following for Full Screen Chat external program }
  389. { added by R. Neal - Corporate Headquarters BBS (815) 886-3233 }
  390.    if exist ('chat.exe') then begin
  391.       if (ansigraphics in urec.config) or (vt52 in urec.config) then begin
  392.          str (baudrate:3,baudst); {convert baud setting to string}
  393.          str (usecom:1,commst);   {convert com port to string}
  394.          exec ('chat.exe ','0 '+commst+' '+baudst);
  395.          setparam(usecom, baudrate, parity);
  396.          clrscr;
  397.          exit;
  398.       end;
  399.     end;
  400. { end of Full Screen Chat mod }
  401.   instruct;
  402.   quit:=false;
  403.   l:=0;
  404.   curcolor:=urec.regularcolor;
  405.   repeat
  406.     linecount:=0;
  407.     if (not carrierloss) and (not carrier) then begin
  408.       carrierloss:=true;
  409.       writeln (^M'No one''s here to chat with!'^M)
  410.     end;
  411.     repeat until keyhit or (carrier and (numchars>0));
  412.     fromkbd:=keyhit;
  413.     ingetstr:=true;
  414.     read (directin,k);
  415.     if k=#127 then k:=#8;
  416.     if requestchat
  417.       then if requestcom
  418.         then
  419.           begin
  420.             quit:=specialcommand;
  421.             if not quit then instruct;
  422.             clearbreak;
  423.             nobreak:=true;
  424.             l:=0
  425.           end
  426.         else
  427.           begin
  428.             unsplit;
  429.             quit:=true
  430.           end;
  431.     case ord(k) of
  432.       8:if l>0 then begin
  433.           write (k+' '+k);
  434.           l:=l-1
  435.         end;
  436.       0:;
  437.       13:begin
  438.            writeln;
  439.            bottomline;
  440.            l:=0
  441.          end;
  442.       32..126:typedchar (k);
  443.       1..31:if fromkbd and carrier then sendchar(k)
  444.     end
  445.   until quit;
  446.   clearbreak
  447. end;
  448.  
  449. begin
  450. end.
  451.