From 08edfbc1fd81d86f492f2f9438a136c139f932ca Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 5 Dec 2025 00:01:23 +0500 Subject: feat: net_post function in lua --- bot/src/commands/lua.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'bot/src/commands/lua.cpp') diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp index 0033cc5..c37f146 100644 --- a/bot/src/commands/lua.cpp +++ b/bot/src/commands/lua.cpp @@ -319,6 +319,24 @@ namespace bot::command::lua { return t; }); + state->set_function( + "net_post", [state](const std::string &url, const sol::table &body) { + sol::table t = state->create_table(); + + cpr::Multipart multipart = {}; + for (auto &kv : body) { + multipart.parts.push_back( + {kv.first.as(), kv.second.as()}); + } + + cpr::Response response = cpr::Post(cpr::Url{url}, multipart); + + t["code"] = response.status_code; + t["text"] = response.text; + + return t; + }); + state->set_function( "net_post_multipart_with_headers", [state](const std::string &url, const sol::table &body, -- cgit v1.2.3