MyChat add-ons: developing, technical questions, testing, documentation and other useful information
User avatar
Alona Kutsenko
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:

OnlyAdvUsersMsgScript.png
Script for blocking messages in MyChat conferences
OnlyAdvUsersMsgScript.png (90.42 KiB) Viewed 2486 times

OnlyAdvUsersMsgScriptResult.png
Script work result in MyChat Client Console
OnlyAdvUsersMsgScriptResult.png (29.43 KiB) Viewed 2486 times


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.