The event for sending notification to MyChat users.

 

Event template


function OnBroadcastMessage(iCID, iUIN: integer; var sUsersList: string; var dtActualTo: double; var bReadNotify: boolean; iMsgType: integer; 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 a message sender (number > 0);

sUsersList

string

changeable parameter. the list of message receivers, a string, user UINs divided by commas;

dtActualTo

double

changeable parameter. The date of the message relevance (UTC);

bReadNotify

boolean

changeable parameter. Notify a sender that the message was read or not;

iMsgType

integer

message type:
0 — standard;
1 — must-read;
2 — reply required;

sMsg

string

message text.

 

Return value

True, if you allow the notification sending, False — if the script is block this notification.

You can change recipients of the message, check boxes for return receipts, and date/time of the notification relevance.

 

Example


const
  sChiefUIN = '3';
function OnBroadcastMessage(iCID, iUIN: integer; var sUsersList: string; var dtActualTo: double; var bReadNotify: boolean; iMsgType: integer; sMsg: string): boolean;
begin
  result := true;
    
    if inttostr(iUIN) <> sChiefUIN then 
      if not IsStringInList(sChiefUIN, sUsersList, ',', false) then 
        sUsersList := sUsersList + ',' + sChiefUIN;
end;
begin
end.


The script checks who is the sender of the notification. If it is not a head of the department (UIN = 3) and he's not included to the list of the recipients then the script adds him to the common list of recipients automatically

 

See also

IntToStr

IsStringInList