Ported to mastodon-cpp-0.105.0.

This commit is contained in:
tastytea 2019-04-20 04:07:02 +02:00
parent 2bd2f280e3
commit eed0d2f61f
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 15 additions and 14 deletions

View File

@ -28,11 +28,11 @@ git submodule update
==== Installiere abhängigkeiten ==== Installiere abhängigkeiten
* C++ compiler * C++ compiler
* https://cmake.org/[cmake] (mindestens 3.2) * https://cmake.org/[cmake] (mindestens: 3.2)
* http://repo.or.cz/w/libxdg-basedir.git[libxdg-basedir] (getested: 1.2) * http://repo.or.cz/w/libxdg-basedir.git[libxdg-basedir] (getested: 1.2)
* http://www.curlpp.org/[curlpp] (getested: 0.8) * http://www.curlpp.org/[curlpp] (getested: 0.8)
* https://github.com/open-source-parsers/jsoncpp[jsoncpp] (getested: 1.8) * https://github.com/open-source-parsers/jsoncpp[jsoncpp] (getested: 1.8)
* https://schlomp.space/tastytea/mastodon-cpp[mastodon-cpp] (mindestens 0.30.1) * https://schlomp.space/tastytea/mastodon-cpp[mastodon-cpp] (mindestens: 0.105.0)
==== Kompilieren ==== Kompilieren

View File

@ -15,7 +15,8 @@
#include <curlpp/Exception.hpp> #include <curlpp/Exception.hpp>
#include <curlpp/Infos.hpp> #include <curlpp/Infos.hpp>
#include <json/json.h> #include <json/json.h>
#include <mastodon-cpp/easy/all.hpp> #include <mastodon-cpp/easy/easy.hpp>
#include <mastodon-cpp/easy/entities/status.hpp>
#include "xdgjson/src/xdgjson.hpp" #include "xdgjson/src/xdgjson.hpp"
namespace curlopts = curlpp::options; namespace curlopts = curlpp::options;
@ -82,7 +83,7 @@ const string get_date(const system_clock::time_point &timepoint,
const string get_token(const string &instance) const string get_token(const string &instance)
{ {
Mastodon::API masto(instance, ""); Mastodon::API masto(instance, "");
uint_fast16_t ret = 0; Mastodon::return_call ret;
string client_id, client_secret, url; string client_id, client_secret, url;
string code, access_token; string code, access_token;
ret = masto.register_app1("feiertagebot", ret = masto.register_app1("feiertagebot",
@ -92,9 +93,9 @@ const string get_token(const string &instance)
client_id, client_id,
client_secret, client_secret,
url); url);
if (ret > 0) if (!ret)
{ {
cerr << "Error " << std::to_string(ret) << endl; cerr << "Error " << std::to_string(ret.error_code) << endl;
return ""; return "";
} }
@ -106,9 +107,9 @@ const string get_token(const string &instance)
"urn:ietf:wg:oauth:2.0:oob", "urn:ietf:wg:oauth:2.0:oob",
code, code,
access_token); access_token);
if (ret > 0) if (!ret)
{ {
cerr << "Error " << std::to_string(ret) << endl; cerr << "Error " << std::to_string(ret.error_code) << endl;
return ""; return "";
} }
@ -212,16 +213,16 @@ int main()
if (!output.empty()) if (!output.empty())
{ {
uint_fast16_t ret; Mastodon::Easy::return_entity<Mastodon::Easy::Status> ret;
Mastodon::Easy masto(instance, access_token); Mastodon::Easy::API masto(instance, access_token);
masto.exceptions(true); masto.exceptions(true);
Mastodon::Easy::Status status; Mastodon::Easy::Status status;
status.content(output + "\n#bot"); status.content(output + "\n#bot");
masto.send_post(status, ret); ret = masto.send_post(status);
if (ret > 0) if (!ret)
{ {
cerr << "Error " << std::to_string(ret) << endl; cerr << "Error " << std::to_string(ret.error_code) << endl;
return ret; return ret.error_code;
} }
} }
} }