Post запрос к telegram боту

EndoHokage

Активный
Автор темы
136
55
Версия MoonLoader
.026-beta
Я использую функцию от FYP для http запросов
Lua:
--Эту
local copas = require 'copas'
local http = require 'copas.http'

function httpRequest(request, body, handler) -- copas.http
    -- start polling task
    if not copas.running then
        copas.running = true
        lua_thread.create(function()
            wait(0)
            while not copas.finished() do
                local ok, err = copas.step(0)
                if ok == nil then error(err) end
                wait(0)
            end
            copas.running = false
        end)
    end
    -- do request
    if handler then
        return copas.addthread(function(r, b, h)
            copas.setErrorHandler(function(err) h(nil, err) end)
            h(http.request(r, b))
        end, request, body, handler)
    else
        local results
        local thread = copas.addthread(function(r, b)
            copas.setErrorHandler(function(err) results = {nil, err} end)
            results = table.pack(http.request(r, b))
        end, request, body)
        while coroutine.status(thread) ~= 'dead' do wait(0) end
        return table.unpack(results)
    end
end
Я пытаюсь сделать post запрос
Lua:
dataError = {
    chat_id = chatid
    text = "Привет"
}
                   
httpRequest('https://api.telegram.org/bot' .. token .. '/' .. 'sendMessage', dataError)
Но ничего не происходит, ошибок нету.
Как это исправить?
Заранее спасибо
 
Последнее редактирование:
  • Нравится
Реакции: Mamory