mysticbbs/mystic/bbs_userchat.pas

133 lines
3.0 KiB
ObjectPascal
Raw Normal View History

2012-03-08 13:39:52 -08:00
Unit bbs_UserChat;
{$I M_OPS.PAS}
Interface
Procedure PageUserForChat;
Procedure OpenUserChat (Forced: Boolean; ToNode: Byte);
Implementation
Uses
m_Strings,
m_FileIO,
m_DateTime,
bbs_Core,
bbs_Common,
bbs_NodeInfo;
Procedure PageUserForChat;
Var
2012-03-10 00:58:11 -08:00
Str : String;
ToNode : Byte;
ReqType : Byte = 8;
TempChat : ChatRec;
2012-03-08 13:39:52 -08:00
Begin
Repeat
2012-03-10 00:58:11 -08:00
Session.io.OutFull ('|CR|09Enter node to chat with |01[|10?|01/|10List|01]|09: ');
2012-03-08 13:39:52 -08:00
Str := Session.io.GetInput(3, 3, 12, '');
If Str = '?' Then Show_Whos_Online Else
If Str = 'Q' Then Exit Else Break;
Until False;
ToNode := strS2I(Str);
2012-03-10 00:58:11 -08:00
If (Not GetChatRecord(ToNode, TempChat)) or (ToNode = Session.NodeNum) or
(Not TempChat.Active) or (Not TempChat.Available) Then Begin
Session.io.OutFull('|CR|15That user is marked unavailable.|CR|CR|PA');
Exit;
2012-03-08 13:39:52 -08:00
End;
If Session.User.Access(Config.ACSSysop) Then
If Session.io.GetYN('|CR|12Force user into chat? ', False) Then
ReqType := 9;
FileErase (Config.DataPath + 'userchat.' + strI2S(ToNode));
FileErase (Config.DataPath + 'userchat.' + strI2S(Session.NodeNum));
2012-03-10 00:58:11 -08:00
Session.io.PromptInfo[1] := TempChat.Name;
2012-03-13 19:32:37 -07:00
Session.io.OutFull('|CR|15Sending chat request to |&1...|DE|DE|CR');
2012-03-08 13:39:52 -08:00
Send_Node_Message (ReqType, strI2S(ToNode) + ';C' + Str, 0);
End;
Procedure OpenUserChat (Forced: Boolean; ToNode: Byte);
2012-03-10 00:58:11 -08:00
Var
fOut : File;
fIn : File;
Ch : Char;
2012-03-13 19:32:37 -07:00
Str1 : String = '';
Str2 : String = '';
2012-03-10 00:58:11 -08:00
Done : Boolean = False;
2012-03-08 13:39:52 -08:00
Begin
2012-03-10 00:58:11 -08:00
Session.io.OutFullLn('|CR|15Chat mode begin.|CR');
Assign (fOut, Config.DataPath + 'userchat.' + strI2S(ToNode));
Assign (fIn, Config.DataPath + 'userchat.' + strI2S(Session.NodeNum));
FileMode := 66;
ReWrite (fOut, 1);
ReWrite (fIn, 1);
While Not Done Do Begin
If Not Eof(fIn) Then
While Not Eof(fIn) Do Begin
BlockRead (fIn, Ch, 1);
If Ch = #255 Then Begin
Done := True;
Break;
End;
Session.io.AnsiColor (Session.Lang.LineChat2);
Session.io.BufAddChar (Ch);
End;
Session.io.BufFlush;
If Done Then Break;
Ch := Session.io.InKey(25);
Case Ch of
2012-03-13 19:32:37 -07:00
#08 : If Screen.CursorX > 1 Then Begin
Str2 := #8#32#8;
BlockWrite (fOut, Str2[1], 3);
Session.io.OutBS(1, True);
End;
#13 : Begin
Str2 := #13#10;
BlockWrite (fOut, Str2[1], 2);
Session.io.OutRawLn('');
End;
2012-03-10 00:58:11 -08:00
#27 : If Not Forced Then Begin
Ch := #255;
BlockWrite (fOut, Ch, 1);
Break;
End;
Else
If Ch in [#32..#254] Then Begin
BlockWrite (fOut, Ch, 1);
Session.io.AnsiColor (Session.Lang.LineChat1);
Session.io.BufAddChar (Ch);
End;
End;
End;
Close(fOut);
Close(fIn);
Erase(fOut);
Erase(fIn);
Session.io.OutFullLn('|CR|CR|15Chat mode complete.|DE|DE|DE');
2012-03-08 13:39:52 -08:00
End;
2012-03-10 00:58:11 -08:00
End.