MyChat add-ons: developing, technical questions, testing, documentation and other useful information
User avatar
Alona Kutsenko
Server from 7.0 and higher.

Use the "OnRegistered" event:

onregisredscript.png
Script to rename users from WEB support automatically
onregisredscript.png (53.81 KiB) Viewed 3239 times

The script works on the event for a new user registration. It checks that a new user has a default rights group "WEB Guests". If yes, the script renames him and adds the prefix "(Web client)" from the text constant.

Script text:
Code: Select all
// ---------------------------------------
// Script created by Alexey Pikurov
// 01.06.2018 15:33:51
// ---------------------------------------
const
  PREFIX = '(Web client)';
 
procedure OnRegistered(iCID, iUIN: integer; var iRole: integer; var bBlocked: boolean);
var
  sGroupName, sNickName: string;
  x: integer;
begin
  sGroupName := mGetRoleNameByID(iRole);
 
    if sGroupName = 'WEB guests' then begin
      sNickName := mGetUserAttribute(iUIN, 'InternalNickName');
     
        if pos(PREFIX, sNickName) = 0 then mSetUserAttribute(iUIN, 'InternalNickName', PREFIX + ' ' + sNickName);
    end;
end;

begin

end.