From 992fe81a56cb2de4f99cb33ac54976240ba70b4a Mon Sep 17 00:00:00 2001 From: TTakaTit Date: Wed, 22 May 2024 01:24:31 +0700 Subject: [PATCH] fix getchat, add logout --- auth.cpp | 14 ++++++++++++++ auth.hpp | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/auth.cpp b/auth.cpp index 2e40236..7d1870b 100644 --- a/auth.cpp +++ b/auth.cpp @@ -216,6 +216,20 @@ void KeyAuth::api::login(std::string username, std::string password) load_user_data(json[(XorStr("info"))]); } +void KeyAuth::api::logout() +{ + checkInit(); + + auto data = + XorStr("type=logout") + + XorStr("&sessionid=") + sessionid + + XorStr("&name=") + name + + XorStr("&ownerid=") + ownerid; + auto response = req(data, url); + auto json = response_decoder.parse(response); + load_response_data(json); +} + void KeyAuth::api::chatget(std::string channel) { checkInit(); diff --git a/auth.hpp b/auth.hpp index 85a9bf4..3b9b3f2 100644 --- a/auth.hpp +++ b/auth.hpp @@ -1,4 +1,4 @@ -#include +#include #pragma comment(lib, "libcurl.lib") @@ -33,6 +33,7 @@ namespace KeyAuth { void button(std::string value); void upgrade(std::string username, std::string key); void login(std::string username, std::string password); + void logout(); std::vector download(std::string fileid); void regstr(std::string username, std::string password, std::string key, std::string email = ""); void chatget(std::string channel); @@ -124,6 +125,7 @@ namespace KeyAuth { void load_channel_data(nlohmann::json data) { api::response.success = data["success"]; api::response.message = data["message"]; + api::response.channeldata.clear(); //If you do not delete the data before pushing it, the data will be repeated. TTakaTit for (const auto sub : data["messages"]) { std::string authoroutput = sub["author"];