- Creat the folder "c:\messages\broadcast\" on a computer with MyChat Server.
- Add text files made in a regular Notepad to this folder. File names are a time when messages should be sent. For example, "17.35.txt" or "8.00.txt". Notepad adds the extension .txt automatically when saving the file, the time must be multiple of five minutes.
- Create one or several users groups on MyChat Server and add people for whom you want to send notifications.
- Create a script on the event "User defined scripts", "Every 5 minutes"; enable the script.
- Profit!
Script source
// ---------------------------------------
// Script created by Alexey Pikurov ([email protected])
// sending notifications on time from text files
// for specified groups of people
// 15.09.2018 14:13:00
// ---------------------------------------
const
sGroupsList = 'Special'; // users groups, divided by commas, no spaces
sPath = 'c:\messages\broadcast\'; // path on the server disk to take files for notifications
var
sFullName, sFileName, sMsg, sUsersList, sCurrentGroup, sGroupsOriginal: string;
iDay: integer;
bFlag: boolean;
begin
iDay := DayOfTheWeek(Now);
sFileName := FormatDatetime('hh.nn', Now) + '.txt'; // for example, 17.45.txt
sGroupsOriginal := sGroupsList;
while length(sGroupsOriginal) > 0 do begin
sCurrentGroup := GetNextSt(sGroupsOriginal, ',');
sFullName := sPath + sFileName;
if FileExists(sFullName) then
if iDay < 6 then begin // run the script on workdays only
sMsg := Trim(LoadTextFromFile(sFullName, 0));
if length(sMsg) > 0 then begin
sUsersList := mGetUsersListInGroupsByNames(sCurrentGroup);
if length(sUsersList) > 0 then
mSendBroadcast(sMsg, sUsersList, EndOfTheDay(Now), 1);
end;
end;
end;
end.