Open the server, the tool "Scripts", and insert the script to the event that will be executed every hour:
Do not forget to enable the script.
//////////////////////////////////////////////////////////////
// //
// MyChat Server Script Language //
// //
// The script for automatic greetings //
// version 1.0 from 02.10.2011 //
// //
// Copyright(c) Alexey Pikurov / Network Software Solutions //
// [email protected] //
// https://nsoft-s.com //
// //
// Execute every hour //
// Questions, ideas, comments: //
// https://nsoft-s.com/mychatforum/viewforum.php?f=35 //
// //
//////////////////////////////////////////////////////////////
var
s, sUserFullName, sMsg, s2, sToday, sOld: string;
iUIN, iSex: integer;
sJSON: string;
begin
sToday := FormatDateTime('mmddyyyy', Now); // get the current date
// read from the register an entry about last launch
RegGetString(HKEY_CURRENT_USER, 'Software\MyChatServerScripts\BirthdayReminder', sOld);
// if we have already worked today, then do nothing
// to avoid repeat same people for the second time
if sToday<>sOld then begin
// write the current date to the registry
RegSetString(HKEY_CURRENT_USER, 'Software\MyChatServerScripts\BirthdayReminder', sToday);
// get the list of user UINs whose birthday is today
s := mGetBirthdayUsers(Now);
// and go though this list one by one
while length(s)>0 do begin
iUIN := strtoint(GetNextSt(s, ','));
sJSON := mGetUserDataAsJSON(iUIN, 'Sex');
JSONGetInteger(sJSON, 'Sex', iSex); // get user's gender
sUserFullName := mGetUserFullNameByPreset(iUIN, 0); // ... and a full name
case iSex of
0, 1: s2 := 'his';
2: s2 := 'her';
end;
// create the line for the greeting
sMsg := 'Today ' + sUserFullName + ' is celebrating the birthday!' +
CRLF +
'Congratulations to ' + s2 + ' and we wish you the best ' +
'of the best!';
// ...and place it on the announcment board to show all the users,
// set the expiration date until the end of the current day
mAddNewBBSMessage(false, sMsg, EndOfTheDay(Now));
end;
end;
end.