"For developers", "Server scripts", "Functions description", "Messages", "mSendPrivateMessage".
Sending a private message on behalf of one user to another.
function mSendPrivateMessage(iUINFrom, iUINTo: integer; sMsg: string; iMsgType: integer; bSaveToHistory: boolean): integer;
Parameter |
Type |
Value |
---|---|---|
iUINFrom |
integer |
sender identifier. You can use the built-in bot (UIN 0) or any other registered user on the server; |
iUINTo |
integer |
recipient identifier (UIN); |
sMsg |
string |
message text. You can use line breaks (CRLF); |
iMsgType |
integer |
Result |
Value |
---|---|
>0 |
all OK, message sent successfully; |
-1 |
sender UIN does not exist; |
-2 |
recipient UIN does not exist; |
-3 |
message cannot be empty; |
-4 |
message can't be sent to yourself. |
This function is linked to the OnPrivateRequest event. When trying to open a private conversation, the script determines, that a user came from the website, from the WEB support chat.
If a user came from WEB support chat for real, then the script sends a private message with the information about user IP, browser User Agent, local language, operating system and referral page, from which the user came from.
Script code is used by Network Software Solutions company in WEB support chat
function OnPrivateRequest(iCID, iUIN, iUINTo, iRole, iRoleReciever, iTask: integer): boolean;
var
s,
sIP, // IP address of WEB support user
sWEBSupportBrowserInfo, // information about web browser
sWEBSupportRefLink, // reflink
sWEBSupportsSysLanguage, // browser local language
sWEBSupportsPlatformOS: string; // user operating system
iCIDTo: integer;
begin
if mGetRoleNameByID(iRole) = 'WEB guests' then begin
sIP := mGetUserAttribute(iUIN, 'IP_Address');
sWEBSupportBrowserInfo := mGetUserAttribute(iUIN, 'WEBSupportBrowserInfo');
sWEBSupportRefLink := mGetUserAttribute(iUIN, 'WEBSupportRefLink');
sWEBSupportsSysLanguage := mGetUserAttribute(iUIN, 'WEBSupportSysLanguage');
sWEBSupportsPlatformOS := mGetUserAttribute(iUIN, 'WEBSupportPlatformOS');
s := '---------------' + CRLF +
'-=WEB Support=-' + CRLF + CRLF +
'IP: ' + sIP;
if length(sWEBSupportBrowserInfo) > 0 then s := s + CRLF + 'Browser: ' + sWEBSupportBrowserInfo + CRLF;
if length(sWEBSupportRefLink) > 0 then s := s + CRLF + 'Reflink: ' + sWEBSupportRefLink;
if length(sWEBSupportsSysLanguage) > 0 then s := s + CRLF + 'System language: ' + sWEBSupportsSysLanguage;
if length(sWEBSupportsPlatformOS) > 0 then s := s + CRLF + 'OS: ' + sWEBSupportsPlatformOS;
mSendPrivateMessage(iUIN, iUINTo, s, 21, true);
iCIDTo := mGetUserCID(iUINTo);
mSendCustomMsgToClientConsoleByCID(iCIDTo, 'WEB support session from UIN ' + inttostr(iUIN), 'newmsg', false, true, 78);
end;
result := true;
end;
begin
end.