fix DPP 10.1.0 or newer build errors

This commit is contained in:
Syping 2025-08-06 18:33:46 +02:00
parent 13d384b14e
commit b2da36e576
8 changed files with 16 additions and 8 deletions

View file

@ -46,7 +46,7 @@ const std::vector<language> mozhi::get_languages()
const std::string parameters = dpp::utility::make_url_parameters({
{"engine"s, m_engine}
});
dpp::https_client http_request(m_hostname, m_port, m_url + "api/target_languages" + parameters, "GET", {}, {}, !m_tls);
dpp::https_client http_request(&m_cluster, m_hostname, m_port, m_url + "api/target_languages" + parameters, "GET", {}, {}, !m_tls);
if (http_request.get_status() == 200) {
const dpp::json response = dpp::json::parse(http_request.get_content());
if (response.is_array()) {
@ -87,7 +87,7 @@ const std::string mozhi::translate(const std::string &text, const std::string &s
{"to"s, target},
{"text"s, text},
});
dpp::https_client http_request(m_hostname, m_port, m_url + "api/translate" + parameters, "GET", {}, {}, !m_tls);
dpp::https_client http_request(&m_cluster, m_hostname, m_port, m_url + "api/translate" + parameters, "GET", {}, {}, !m_tls);
if (http_request.get_status() == 200) {
const dpp::json response = dpp::json::parse(http_request.get_content());
if (response.is_object()) {

View file

@ -20,6 +20,7 @@
#define TRANSLATOR_MOZHI_H
#include <cstdint>
#include <dpp/cluster.h>
#include "../../core/translator.h"
namespace bot {
@ -33,6 +34,7 @@ namespace bot {
const std::string translate(const std::string &text, const std::string &source, const std::string &target) override;
private:
dpp::cluster m_cluster;
std::string m_engine;
std::string m_hostname;
supported_languages m_languages;