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
* 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://www.curlpp.org/[curlpp] (getested: 0.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

View File

@ -15,7 +15,8 @@
#include <curlpp/Exception.hpp>
#include <curlpp/Infos.hpp>
#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"
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)
{
Mastodon::API masto(instance, "");
uint_fast16_t ret = 0;
Mastodon::return_call ret;
string client_id, client_secret, url;
string code, access_token;
ret = masto.register_app1("feiertagebot",
@ -92,9 +93,9 @@ const string get_token(const string &instance)
client_id,
client_secret,
url);
if (ret > 0)
if (!ret)
{
cerr << "Error " << std::to_string(ret) << endl;
cerr << "Error " << std::to_string(ret.error_code) << endl;
return "";
}
@ -106,9 +107,9 @@ const string get_token(const string &instance)
"urn:ietf:wg:oauth:2.0:oob",
code,
access_token);
if (ret > 0)
if (!ret)
{
cerr << "Error " << std::to_string(ret) << endl;
cerr << "Error " << std::to_string(ret.error_code) << endl;
return "";
}
@ -212,16 +213,16 @@ int main()
if (!output.empty())
{
uint_fast16_t ret;
Mastodon::Easy masto(instance, access_token);
Mastodon::Easy::return_entity<Mastodon::Easy::Status> ret;
Mastodon::Easy::API masto(instance, access_token);
masto.exceptions(true);
Mastodon::Easy::Status status;
status.content(output + "\n#bot");
masto.send_post(status, ret);
if (ret > 0)
ret = masto.send_post(status);
if (!ret)
{
cerr << "Error " << std::to_string(ret) << endl;
return ret;
cerr << "Error " << std::to_string(ret.error_code) << endl;
return ret.error_code;
}
}
}