Script for limiting communication in common conferences

In the constants, list the conference names where the limitation is on, and the rights groups with users who are allowed to send messages to these conferences. All other users are ignored. MyChat Client console displays a message (optional).
The script deals with the event OnConfMessage:
The script deals with the event OnConfMessage:
Code: Select all
// ---------------------------------------
// Script created by Alexey Pikurov ([email protected])
// 17.01.2021 12:24:45
// ---------------------------------------
const
NOTIFY_FLAG = true; // true/false: notify a user that he can't write messages in a conference
RESTRICTED_CONFS = '|main|work|sales|Chief|';
ALLOWED_ROLES = '|Administrators|Operators|';
function OnConfMessage(iCID, iUIN, iUID, iMsgType: integer; sConfName, sMsg: string): boolean;
var
sRoleName: string;
bFlag: boolean;
begin
bFlag := true;
if pos('|' + sConfName + '|', RESTRICTED_CONFS) <> 0 then begin
sRoleName := mGetUserRoleName(iUIN);
if pos('|' + sConfName + '|', ALLOWED_ROLES) = 0 then begin
bFlag := false;
if NOTIFY_FLAG then
mSendCustomMsgToClientConsoleByCID(iCID,
'Sorry, but you can not send messages to the conference #main' + sConfName,
'Status', true, true, 74);
end;
end;
result := bFlag;
end;
begin
end.