MyChat Scripts Engine: mGetUserDepartmentID, user's group ID in the common contact list
Getting the numeric identifier of a group in the tree-like common list by user UIN.
Syntax
function mGetUserDepartmentID(iUIN: integer): integer;
Parameters and return values
Parameter |
Type |
Value |
iUIN |
integer |
unique user identifier. |
Function result
Group identifier. If the common contact list is empty or user UIN does not exist in the common contact list, the function returns "-1".
Example
var
i, iMax, iDeptID: integer;
s: string;
begin
iMax := mGetMaxRegisteredUIN;
s := '';
for i := 1 to iMax do
if mIsUINExists(i) then begin
iDeptID := mGetUserDepartmentID(i);
if iDeptID > 0 then begin
s := s +
'User UIN ' + inttostr(i) +
', Name: "' + mGetUserAttribute(i, 'DisplayName') + '" ' +
'is in common contacts list: "' + mGetDepartmentTextPathByID(iDeptID) + '"' +
CRLF;
end;
end;
if length(s) > 0 then mLogScript(s, '')
else mLogScript('Common contacts list is empty!', '');
end.
Script work result
[17:13:32] (Log "mGetUserDepartmentID"): User UIN 3, Name: "Andrew Rakov" is in common contacts list: "MyChat\Teamleads developers"
User UIN 6, Name: "Alexey Pikurov" is in common contacts list: "MyChat\Teamleads developers"
User UIN 5454, Name: "Notebook Acerov" is in common contacts list: "MyChat developers"
User UIN 15427, Name: "Heorhii Lysenko" is in common contacts list: "MyChat developers"
[17:13:32] (Run "mGetUserDepartmentID"): Script operation time: 687 ms
[17:13:32] (Run "mGetUserDepartmentID"): Script done successfully.