MyChat Scripts Engine: mGetUserDepartmentName, user's group name in the comon contact list
Getting a department name from the common contact list by user identifier (UIN).
Syntax
function mGetUserDepartmentName(iUIN: integer): string;
Parameters and return values
Parameter |
Type |
Value |
iUIN |
integer |
unique user identifier. |
Function result
Group name. If the common contact list is empty, user UIN does not exist or not located in the common contact list the function returns an empty string.
Example
In this example we listed all server users, beginning from UIN = 1. If someone of them in the common list, the script displays this user UIN, his name in the chat and group name in the common contact list.
var
i, iMax: integer;
s, sName: string;
begin
iMax := mGetMaxRegisteredUIN;
s := '';
for i := 1 to iMax do
if mIsUINExists(i) then begin
sName := mGetUserDepartmentName(i);
if length(sName) > 0 then begin
s := s +
'User UIN ' + inttostr(i) +
', Name: "' + mGetUserAttribute(i, 'DisplayName') + '" ' +
'is in common contacts list, group : "' + sName + '"' +
CRLF;
end;
end;
if length(s) > 0 then mLogScript(s, '')
else mLogScript('Common contacts list is empty!', '');
end.
Script work result
[11:48:05] (Log "mGetUserDepartmentName"): User UIN 3, Name: "Andrew Rakov" is in common contacts list, group : "Teamleads"
User UIN 6, Name: "Alexey Pikurov" is in common contacts list, group : "Sales department"
User UIN 5454, Name: "Notebook Acerov" is in common contacts list, group : "Bookkeeping"
User UIN 15427, Name: "Heorhii Lysenko" is in common contacts list, group : "MyChat developers"
[11:48:05] (Run "mGetUserDepartmentName"): Script operation time: 703 ms
[11:48:05] (Run "mGetUserDepartmentName"): Script done successfully.