function onReceivePacket(id, bs)
if jsonConfig['notifications'].logCalls then
if id == 220 then
local success = pcall(function()
raknetBitStreamReadInt8(bs)
local rpcId = raknetBitStreamReadInt8(bs)
if rpcId == 17 then
raknetBitStreamReadInt32(bs)
local lenCall = raknetBitStreamReadInt32(bs)
if lenCall and lenCall > 0 and lenCall <= 1024 then
local textCall = raknetBitStreamReadString(bs, lenCall)
local eventCall, dataCall = textCall:match('window%.executeEvent%(\'([%w.]+)\',%s*\'(.+)\'%)')
if eventCall == 'event.call.InitializeCaller' then
local okCall, jsonCall = pcall(decodeJson, dataCall)
if okCall and jsonCall[1] and (lastCall + 2) < os.clock() then
lastCall = os.clock()
sendTelegramNotification('Входящий вызов!\nВам звонит ' .. jsonCall[1])
end
end
end
end
end)
if not success then
end
end
end
local notificationsJoinLeave = {
[34] = {'Вы подключились к серверу!', 'ID_CONNECTION_REQUEST_ACCEPTED', jsonConfig['notifications'].join},
[35] = {'Попытка подключения не удалась!', 'ID_CONNECTION_ATTEMPT_FAILED', jsonConfig['notifications'].join},
[37] = {'Неправильный пароль от сервера!', 'ID_INVALID_PASSWORD', jsonConfig['notifications'].join}
}
if notificationsJoinLeave[id] and notificationsJoinLeave[id][3] then
sendTelegramNotification(notificationsJoinLeave[id][1])
end
local notificationsJoinLeaveIfAuto = {
[32] = {'Сервер закрыл соединение!', 'ID_DISCONNECTION_NOTIFICATION', jsonConfig['notifications'].join},
[33] = {'Соединение потеряно!', 'ID_CONNECTION_LOST', jsonConfig['notifications'].join},
}
if notificationsJoinLeaveIfAuto[id] and notificationsJoinLeaveIfAuto[id][3] and not jsonConfig['settings'].autoQ and not jsonConfig['settings'].autoOff then
sendTelegramNotification(notificationsJoinLeaveIfAuto[id][1])
end
local LocalAutoQ = {
[32] = {'Сервер закрыл соединение!', 'ID_DISCONNECTION_NOTIFICATION', jsonConfig['settings'].autoQ},
[33] = {'Соединение потеряно!', 'ID_CONNECTION_LOST', jsonConfig['settings'].autoQ},
}
if LocalAutoQ[id] and LocalAutoQ[id][3] then
sendTelegramNotification(LocalAutoQ[id][1] .. '\nВаша игра выключена.')
ffi.C.ExitProcess(0)
end
local LocalAutoOff = {
[32] = {'Сервер закрыл соединение!', 'ID_DISCONNECTION_NOTIFICATION', jsonConfig['settings'].autoOff},
[33] = {'Соединение потеряно!', 'ID_CONNECTION_LOST', jsonConfig['settings'].autoOff},
}
if LocalAutoOff[id] and LocalAutoOff[id][3] then
sendTelegramNotification(LocalAutoOff[id][1] .. '\nВаш компьютер выключен.')
os.execute('shutdown /s /t 5')
end
end