Script event for MyChat Server: OnBBSMessage

Script event for MyChat Server: OnBBSMessage

Event for creating a new message on the common announcement board of MyChat messenger.

 

Event template

function OnBBSMessage(iCID, iUIN: integer; bStick: boolean; dtPosted, dtExpire: double; sMsg: string): boolean;
begin
  // your own code  
  
  result := true;
end;

begin

end.

You can put your code instead of the comment.

 

Description of parameters

Parameter

Type

Value

iCID

integer

Connection ID of the client, unique session identifier in the online structure of network connections to the server;

iUIN

integer

unique identifier of the message sender (number > 0);

bStick

boolean

"pinned" announcement. If truе — place a message on top of all messages on the board;

dtPosted

double

date/time of the message placement on the board;

dtExpire

double

date/time of the announcement relevance. When it expires  the announcement will be archived;

sMsg

string

message text.

 

Return value

True, if you allow to place an announcement on the board, False — if not.

 

Example

const
  sFileName = 'c:\denwer\home\company\www\bbs.html';

function OnBBSMessage(iCID, iUIN: integer; bStick: boolean; dtPosted, dtExpire: double; sMsg: string): boolean;
var
  s: string;
begin
  s := ReplaceString(sMsg, '<', '<', true, false);
  s := ReplaceString(s, '>', '>', true, false);
  
  s := '' + CRLF +
       '' + CRLF +
       s +
       '

' + CRLF + FormatDateTime('[dd.mm.yyyy hh:nn]', dtPosted) + ' ' + mGetUserAttribute(iUIN, 'DisplayName') + CRLF + '' + CRLF + ''; DeleteFile(sFileName); AddLineToFile(s, sFileName); result := true; end; begin end.

The script creates html-file for placement on the corporate WEB server, where it duplicates the message text and indicates the sender and the date of the announcement placement.

 

When you place the message on the announcement on the board it displayed in the chat:

 

New message on MyChat announcment bord

 

Also, the HTML file is created  in "c:\denwer\home\company\www\bbs.html":

 

HTML file with a text of the announcement that is created by the script OnBBSMessageon MyChat Server

 

It looks like in a browser:

 

Text of a new announcement that is created in MyChat, opened in a browser, on a corporate WEB server

 

See also

AddLineToFile

CRLF

DeleteFile

FormatDateTime

mGetUserAttribute

ReplaceString