diff options
| author | ilotterytea <iltsu@alright.party> | 2025-12-05 00:01:23 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-12-05 00:01:23 +0500 |
| commit | 08edfbc1fd81d86f492f2f9438a136c139f932ca (patch) | |
| tree | 1f5ed4fb060f0f53194d740f741ae38b501652bd | |
| parent | 6711c33204deb3a10eb447f74813352ff24ec8e6 (diff) | |
feat: net_post function in lua
| -rw-r--r-- | bot/src/commands/lua.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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 @@ -320,6 +320,24 @@ namespace bot::command::lua { }); 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<std::string>(), kv.second.as<std::string>()}); + } + + 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, const sol::table &headers) { |
