Тут типо читаем/создаём массив с файла
Код
global DirectWords = "C:\Users\Dell\Desktop\x.txt"
global DirectChat = "C:\GTA San Andreas User Files\SAMP\chatlog.txt" ; Лично у меня генерируеться на диске C
;~ global DirectChat = % A_MyDocuments "\GTA San Andreas User Files\SAMP\chatlog.txt" ; Стандартный путь для всех (Мои Документы)
IfNotExist, %A_ScriptDir%\Words.txt
{
if (GenWordsFile())
MsgBox, Базовый файл - сгенерирован
}
Words := Object()
Loop, Read, % DirectWords
{
Words.Insert(A_LoopReadLine)
}
GenWordsFile() ; генерация базового файла
{
GenWords=<br / <img src="/.s/sm/2/angry.gif" border="0" align="absmiddle" alt="angry" />
Когда призыв
)
FileDelete, %A_ScriptDir%\Words.txt
FileAppend, %GenWords%, %A_ScriptDir%\Words.txt, UTF-8
return True
}
Ищем по чат-логу
Код
Loop
{
chatline := GetNewLine(DirectChat) ; Пока размер файла не измениться ничего не делаем
if (RegExMatch(chatline, "^\[\d{2}:\d{2}:\d{2}\] (\w+)\[(\d{1,3})\] говорит: (.*)", mKey))
{
for index, fword in Words
{
if (InStr(mKey3, fword))
{
MsgBox, %fword% " - найден "
SendChat("/ans " match2 " Администрация желает вам приятной игры! ")
}
}
}
}
GetNewLine(filename) ; Минус данной функции в том что она зациклина на изменение размера файла // Иные функции нужно запускать через таймер
{
static old
static new
if !old
{
FileGetSize, old, %filename%
new := old
}
while old = new
{
sleep 500
FileGetSize, new, %filename%
}
old := new
Loop, read, %filename%
if A_LoopReadLine
last := A_LoopReadLine
return last
}