MyChat Scripts Engine: mSetUserAttribute, change a user's attribute
Editing the user's profile data by his attribute.
Syntax
function mSetUserAttribute(iUIN: integer; sAttributeName, sValue: string): integer;
Parameters and return values
Parameter |
Type |
Value |
iUIN |
integer |
unique user identifier; |
sAttributeName |
string |
name of the attribute from the profile, that you want to change. The letter case is not important; |
sValue |
string |
attribute value. |
List of user's available fields that can be edited
Name |
Description |
Tag |
text tag, special field; |
UserDomainName |
user's domain name; |
InternalNickName |
user's nickmane. If it is a domain user this is his domain name; |
Active |
active or blocked account of the user (1 or 0); |
FirstName |
user's real name; |
MiddleName |
user's middle name; |
LastName |
user's last name; |
Home_MaritalStatus |
|
Home_Phone |
home phone; |
Home_Fax |
home fax; |
Home_Birthday |
date of birth in mm.dd.yyyy format; |
|
main email address; |
Home_Cellular |
personal mobile number; |
Home_StreetAddress |
home address; |
Home_City |
home city; |
Home_State |
state/province/region/district; |
Home_ZIP |
home ZIP code; |
Home_Country |
|
Home_WWW |
personal WEB-page; |
Work_Position |
work position; |
Work_CompanyName |
company name; |
Work_Office |
work office; |
Work_Phone |
work phone number; |
Work_Fax |
work fax; |
Work_Pager |
work pager or messenger number; |
Work_StreetAddress |
work address; |
Work_City |
work city; |
Work_State |
work state/province/region/district; |
Work_ZIP |
work ZIP code; |
Work_Country |
|
Work_WWW |
work WEB page; |
Spoken_Lang_1 |
spoken language, number 1; |
Spoken_Lang_2 |
spoken language, number 2; |
Spoken_Lang_3 |
spoken language, number 3; |
Interest_Section_1 |
interests section, number 1; |
Interest_Section_2 |
interests section, number 2; |
Interest_Section_3 |
interests section, number 3; |
Interest_Section_4 |
interests section, number 4; |
Interest_Words_1 |
interests section, key words, number 1; |
Interest_Words_2 |
interests section, key words, number 2; |
Interest_Words_3 |
interests section, key words, number 3; |
Interest_Words_4 |
interests section, key words, number 4; |
History_Section_1 |
type of the previous place of work or study, number 1; |
History_Section_2 |
type of the previous place of work or study, number 2; |
History_Section_3 |
|
History_Words_1 |
type of the previous place of work or study, key words number 1; |
History_Words_2 |
type of the previous place of work or study, key words number 2; |
History_Words_3 |
type of the previous place of work or study, key words number 3; |
Past_Organization_1 |
type of the organization, previous place of work, number 1; |
Past_Organization_2 |
type of the organization, previous place of work, number 2; |
Past_Organization_3 |
type of the organization, previous place of work, number 3; |
Past_Organization_Words_1 |
type of the organization, previous place of work, key words number 1; |
Past_Organization_Words_2 |
type of the organization, previous place of work, key words number 2; |
Past_Organization_Words_3 |
type of the organization, previous place of work, key words number 3; |
Sex |
|
Hello_Message |
greeting message, if available. Displays to all users, who opened the chat with this person; |
Autoreplay_Message |
auto-reply message; |
Autoreplay |
enabled/disabled answerphone (1 — enabled, 0 — disabled); |
About |
information field "About user"; |
Custom_1 |
text custom field number 1; |
Custom_2 |
text custom field number 2; |
Custom_3 |
text custom field number 3. |
Function result
0 |
function done successfully; |
-1 |
specified nonexistent user; |
-2 |
specified invalid attribute; |
-3 |
you cannot set attributes for the bot (UIN = 0); |
-4 |
attribute contents cannot be empty. |
Example
In the settings section to form the appearance of the user's name, set "%nick% %custom1%". The user's name will be composed of the nick and some variable, that you take from the script. Each user has his computer name. If the user changes his device, then you edit his custom field in the profile to display his status as "on the road", change his computer name to "TOSHIBA-..." (if he works on the notebook) or "office", if the computer name is "COMP....", etc.
Bind the process to the OnUserLogin event:
function OnUserLogin(iCID, iLoginUIN, iLoginState: integer; sLoginIP, sLoginMAC, sLoginHardwareID, sLoginCompName, sLoginVersion, sLoginDomain, sSessionID, sAuthService, sClientType, sRemoteOS: string): boolean;
var
s, sWhere: string;
begin
s := LowerCase(sLoginCompName);
sWhere := '';
if pos('toshiba', s) <> 0 then sWhere := '(on the road)' else
if pos('comp-', s) <> 0 then sWhere := '(office)' else
if pos('kiev', s) <> 0 then sWhere := '(with the customer)';
mSetUserAttribute(iLoginUIN, 'custom_1', sWhere);
result := true;
end;
begin
end.
Script work result
The user is logged on the computer with the name "TOSHIBA-PC":