Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <restclient-cpp/restclient.h>
- #include <parallel_hashmap/phmap.h>
- #include <unidokkan/database.h>
- #include <nlohmann/json.hpp>
- #include <unidokkan/hook.h>
- #include <unidokkan/log.h>
- #include <dokkan/crypto.h>
- #include <string>
- bool ShowEventsBanners(NetworkResponse *response) {
- using namespace std::string_view_literals;
- using json = nlohmann::json;
- UD_LOGI("Translation Event List : Loading . . .");
- constexpr std::string_view kGetQuests = R"SQL(SELECT
- quests.id,
- quests.name
- FROM
- quests)SQL"sv;
- phmap::parallel_flat_hash_map<int, json> Quests_List_Keyed = UniDokkan::Database::selectKeyedInt(kGetQuests, 0);
- for (auto &EventList_Kagi : response->jsonBody["eventkagi_events"]) {
- auto Event_ID_int = EventList_Kagi["id"];
- std::string Event_ID_long = to_string(EventList_Kagi["id"]);
- std::string Event_ID = Event_ID_long.substr(0, 3);
- for (auto &Quests_Name_Kagi : EventList_Kagi["quests"]) {
- int Quest_ID = Quests_Name_Kagi["id"];
- std::string Quest_Name = Quests_List_Keyed[Quest_ID]["name"].get<std::string>();
- Quests_Name_Kagi["name"] = Quest_Name;
- }
- bool Need_to_check = false;
- if (Event_ID_int >= 200) {if (Event_ID_int <= 299) {Need_to_check = true;}}
- if (Event_ID_int >= 377) {if (Event_ID_int <= 399) {Need_to_check = true;}}
- if (Event_ID_int >= 422) {if (Event_ID_int <= 499) {Need_to_check = true;}}
- if (Event_ID_int >= 557) {if (Event_ID_int <= 599) {Need_to_check = true;}}
- if (Event_ID_int >= 605) {if (Event_ID_int <= 699) {Need_to_check = true;}}
- if (Event_ID_int >= 710) {if (Event_ID_int <= 799) {Need_to_check = true;}}
- auto urlcheck = RestClient::head("https://www.baoulettes.fr/DokkanEvent/image/quest_list_banner_" + Event_ID + ".png");
- if (Need_to_check == true && urlcheck.code == 200) {
- EventList_Kagi["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_list_banner_" + Event_ID + ".png";
- } else {
- std::string logstring = "quest_list_banner_" + Event_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- auto urlcheck1 = RestClient::get("https://www.baoulettes.fr/DokkanEvent/image/quest_top_banner_" + Event_ID + ".png");
- if (urlcheck1.code == 200) {
- EventList_Kagi["event_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_top_banner_" + Event_ID + ".png";
- } else {
- std::string logstring = "quest_top_banner_" + Event_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- auto urlcheck2 = RestClient::get("https://www.baoulettes.fr/DokkanEvent/image/quest_event_banner_" + Event_ID + ".png");
- if (urlcheck2.code == 200) {
- EventList_Kagi["minibanner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_event_banner_" + Event_ID + ".png";
- } else {
- std::string logstring = "quest_event_banner_" + Event_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- }
- for (auto &EZAList_Kagi : response->jsonBody["eventkagi_z_battle_stages"]) {
- std::string EZA_ID = to_string(EZAList_Kagi["id"]);
- auto urlcheck3 = RestClient::get("https://www.baoulettes.fr/DokkanEvent/image/zbattle_list_banner_" + EZA_ID + ".png");
- if (urlcheck3.code == 200) {
- EZAList_Kagi["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/zbattle_list_banner_" + EZA_ID + ".png";
- } else {
- std::string logstring = "zbattle_list_banner_" + EZA_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- }
- for (auto &EventList : response->jsonBody["events"]) {
- std::string Event_ID_long = to_string(EventList["id"]);
- std::string Event_ID = Event_ID_long.substr(0, 3);
- for (auto &Quests_Name : EventList["quests"]) {
- int Quest_ID = Quests_Name["id"];
- std::string Quest_Name = Quests_List_Keyed[Quest_ID]["name"].get<std::string>();
- Quests_Name["name"] = Quest_Name;
- auto LimitedEvent = Quests_Name.find("limitations");
- if (LimitedEvent != Quests_Name.end()) {
- for (auto &Limitations : Quests_Name["limitations"]) {
- std::string LimiType = Limitations["type"].get<std::string>();
- if (LimiType == "QuestLimitation::CardQuestLimitation::OnlyCardQuestLimitation") {
- Limitations["description"] = "{relatedCharacterListBtn: card_id:1015141}";
- }
- }
- }
- }
- auto urlcheck4 = RestClient::get("https://www.baoulettes.fr/DokkanEvent/image/quest_list_banner_" + Event_ID + ".png");
- if (urlcheck4.code == 200) {
- EventList["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_list_banner_" + Event_ID + ".png";
- } else {
- std::string logstring = "quest_list_banner_" + Event_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- auto urlcheck5 = RestClient::get("https://www.baoulettes.fr/DokkanEvent/image/quest_top_banner_" + Event_ID + ".png");
- if (urlcheck5.code == 200) {
- EventList["event_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_top_banner_" + Event_ID + ".png";
- } else {
- std::string logstring = "quest_top_banner_" + Event_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- auto urlcheck6 = RestClient::get("https://www.baoulettes.fr/DokkanEvent/image/quest_event_banner_" + Event_ID + ".png");
- if (urlcheck6.code == 200) {
- EventList["minibanner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_event_banner_" + Event_ID + ".png";
- } else {
- std::string logstring = "quest_event_banner_" + Event_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- }
- for (auto &EZAList : response->jsonBody["z_battle_stages"]) {
- std::string EZA_ID = to_string(EZAList["id"]);
- auto urlcheck7 = RestClient::get("https://www.baoulettes.fr/DokkanEvent/image/zbattle_list_banner_" + EZA_ID + ".png");
- if (urlcheck7.code == 200) {
- EZAList["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/zbattle_list_banner_" + EZA_ID + ".png";
- } else {
- std::string logstring = "zbattle_list_banner_" + EZA_ID + ".png";
- UD_LOGI("Translation Event List : Error 404 : %s", logstring.c_str());
- }
- }
- return true;
- }
- extern "C" {
- int unidokkan_init_v2(HookLib* hook_lib) {
- hook_lib->addResponseHook("^/events$", ShowEventsBanners);
- if (!hook_lib) {
- UD_LOGI("Translation Event List : Not Loaded");
- return 1;
- }
- UD_LOGI("Translation Event List : Loaded");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement