Include SAMP ahk global chatLog new LogRead A_MyDocuments GTA San Andr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#Include, SAMP.ahk
global chatLog := new LogRead( A_MyDocuments "\GTA San Andreas User Files\SAMP\chatlog.txt")
SetTimer, main, 200
main:
messages := chatLog.getLastStr()
for k, v in messages
{
if (RegExMatch(v, "\]\s\[(?<Type>Жалоба)\]\W+\[(?<Id>[0-9]+)\]\:{[F]+}\s(?<Ask>.*).\sУже [0-9]+ жалоб!!!") && !isDialogOpen() && !isChatOpen())
SendChat("/ot")
}
Return
class LogRead
{
__New(LogWay)
{
this.LogWay := LogWay
this.sizeLast := 0
}
getLastStr()
{
FileGetSize, fileSize, % this.LogWay
if(fileSize <= this.sizeLast || this.sizeLast == 0)
{
this.sizeLast := fileSize
Return
}
file := FileOpen(this.LogWay, "r")
file.Seek(this.sizeLast)
fileText := file.Read()
file.Close()
this.sizeLast := fileSize
Return StrSplit(fileText, "`r`n")
}
}