Example of a simple MSL script | All articles |
Goal: to circulate the list of user information of an arbitrary character.
For example, a provider of Internet services. In this organization connected to a certain number of users, and to communicate on the internal network provider is used MyChat. Often, some subscribers did not pay on time service provider, or simply forget about it. ISP may notify its subscribers about the need to make a subscription fee with MSL – MyChat Script Language. This built-in script machine in MyChat Server. Features of this system is very broad.
First you must create a plain text file, which will be listed UIN-s debtors and periods, as well as a file with text messages to them.
For example, a file with the UIN-s «С:\UIN.txt» (format “user|date”), on a computer with MyChat Server contains the text:
5|01.07.2009-31.07.2009 678|01.07.2009-31.07.2009 4|01.07.2009-31.07.2009 567|01.07.2009-31.07.2009 56|01.07.2009-31.07.2009 456|01.06.2009-31.07.2009 67|01.07.2009-31.07.2009 34|01.07.2009-31.07.2009 5|01.07.2009-31.07.2009 7|01.07.2009-31.07.2009 97|01.06.2009-31.07.2009 44|01.07.2009-31.07.2009 676|01.07.2009-31.07.2009
A file with text messages «C:\MSG.txt» looks like this:
%user please pay for the service access to the Internet, for the period %date. Failure to pay within 2 business days - you will be disconnected
Now consider the process of creating a script that will send this message debtors every 4 hours.
For that, go to the script editor on the server:
And choose from the list of events - the script every 4-th hour:
We add our script:
Program UsersAlerts; Var UsersCount, I, Uin: integer; Str, Msg, ms, Date, User: string; Begin Msg:=''; // obtain the number of lines in a file with the debtors UsersCount:= GetTextFileLinesCount('c:\uin.txt'); For i:=1 to GetTextFileLinesCount('c:\msg.txt') do Begin // in this cycle load file and merge it into one line LoadLineFromFile('c:\MSG.txt',i,str); Msg:=Msg+str+#13#10; End; For i:=1 to UsersCount do Begin ms:=msg; //save Msg to ms LoadLineFromFile('c:\UIN.txt',i,str);//load line from file UIN:=strtoint(copy(str,1,pos('|',str)-1));//get Uin Users Date:=copy(str,pos('|',str)+1,length(str)-pos('|',str));//get date User:=mGetNickFromUIN(UIN);//ask nick his UIN //replace in the message %user to nick Insert(User,Ms,pos('%user',ms)); Delete(Ms,pos('%user',ms),5); //replace in the message %date to date Insert(Date,Ms,pos('%date',ms)); Delete(Ms,pos('%date',ms),5); //and send the generated message to the user mSendPrivateMessage(uin, Ms); End; End.
Will it look like this:

Click on the icon with a floppy disk, save the script and check «Enable script».
Done, the server will perform the tasks every 4 hours and notify the debtors.
| < <<<===== | =====>>> > |
|---|


