MyChat Scripts Engine: mIsUserInGroup, check if a user is a group member
Function to check if a user exists in a specified group.
Syntax
function mIsUserInGroup(iUIN: integer; sGroupName: string): boolean;
Parameters and return values
Parameter |
Type |
Value |
iUIN |
integer |
user numeric ID; |
sGroupName |
string |
user's group name. The letter case is important. |
Function result
True user in the group, false group with such name does not exist or the user is not in the group.
Example
const
USER_UIN = 6;
GROUPS_LIST = 'Administrators,Moderators,Others';
var
sData, sName, s, sUserName: string;
begin
sData := GROUPS_LIST;
sUserName := mGetUserAttribute(USER_UIN, 'DisplayName');
mLogScript('User "' + sUserName + '" is on the group list?', '');
while length(sData) > 0 do begin
sName := GetNextSt(sData, ',');
if mIsUserInGroup(USER_UIN, sName) then s := 'YES'
else s := 'NO';
mLogScript(sName, s);
end;
end.
Script work result
[18:22:38] (Log "mIsUserInGroup"): User "Alexey Pikurov" is on the group list?
[18:22:38] (Log "mIsUserInGroup"): [YES] Administrators
[18:22:38] (Log "mIsUserInGroup"): [NO] Moderators
[18:22:38] (Log "mIsUserInGroup"): [NO] Others
[18:22:38] (Run "mIsUserInGroup"): Script operation time: 6 ms
[18:22:38] (Run "mIsUserInGroup"): Script done successfully.