Erste fortschritte.
This commit is contained in:
parent
f991a74f3c
commit
368cd91bf3
|
@ -7,6 +7,8 @@ include(GNUInstallDirs)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(LIBXDG_BASEDIR REQUIRED libxdg-basedir)
|
pkg_check_modules(LIBXDG_BASEDIR REQUIRED libxdg-basedir)
|
||||||
pkg_check_modules(LIBCONFIG REQUIRED libconfig++)
|
pkg_check_modules(LIBCONFIG REQUIRED libconfig++)
|
||||||
|
pkg_check_modules(CURLPP REQUIRED curlpp)
|
||||||
|
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
@ -18,12 +20,19 @@ set(CMAKE_CXX_FLAGS_DEBUG
|
||||||
include_directories(${PROJECT_BINARY_DIR})
|
include_directories(${PROJECT_BINARY_DIR})
|
||||||
include_directories(${LIBXDG_BASEDIR_INCLUDE_DIRS})
|
include_directories(${LIBXDG_BASEDIR_INCLUDE_DIRS})
|
||||||
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
||||||
|
include_directories(${CURL_INCLUDE_DIRS})
|
||||||
|
include_directories(${CURLPP_INCLUDE_DIRS})
|
||||||
|
include_directories(${JSONCPP_INCLUDE_DIRS})
|
||||||
|
|
||||||
link_directories(${LIBXDG_BASEDIR_LIBRARY_DIRS})
|
link_directories(${LIBXDG_BASEDIR_LIBRARY_DIRS})
|
||||||
link_directories(${LIBCONFIG_LIBRARY_DIRS})
|
link_directories(${LIBCONFIG_LIBRARY_DIRS})
|
||||||
|
link_directories(${CURL_LIBRARY_DIRS})
|
||||||
|
link_directories(${CURLPP_LIBRARY_DIRS})
|
||||||
|
link_directories(${JSONCPP_LIBRARY_DIRS})
|
||||||
|
|
||||||
add_executable(${CMAKE_PROJECT_NAME} feiertagebot.cpp)
|
add_executable(${CMAKE_PROJECT_NAME} feiertagebot.cpp)
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||||
"${LIBXDG_BASEDIR_LDFLAGS} ${LIBCONFIG_LDFLAGS}"
|
"${LIBXDG_BASEDIR_LDFLAGS} ${LIBCONFIG_LDFLAGS}"
|
||||||
|
"${CURLPP_LDFLAGS} ${JSONCPP_LDFLAGS}"
|
||||||
"-lstdc++fs")
|
"-lstdc++fs")
|
||||||
install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
19
README.adoc
19
README.adoc
|
@ -1,19 +1,16 @@
|
||||||
= feiertagebot
|
= feiertagebot
|
||||||
|
|
||||||
*feiertagebot* ist ein Mastodon-bot, der über anstehende feiertage in
|
*feiertagebot* ist ein Mastodon-bot, der über anstehende feiertage in
|
||||||
Deutschland informiert. Die daten stammen von
|
Deutschland informiert. Die daten stammen von https://feiertage-api.de/.
|
||||||
https://github.com/wlbr/feiertage.
|
|
||||||
|
|
||||||
== Installation und benutzung
|
== Dependencies
|
||||||
|
|
||||||
[source,shell]
|
* C++ compiler
|
||||||
----
|
* [cmake](https://cmake.org/) (at least 3.2)
|
||||||
wget https://schlomp.space/tastytea/feiertagebot/raw/branch/master/feiertagebot
|
* [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git) (tested: 1.2)
|
||||||
chmod +x feiertagebot
|
* [libconfig++](https://github.com/hyperrealm/libconfig) (tested: 1.5)
|
||||||
echo "token=<your token here>" > ~/.config/feiertagebot.cfg
|
* [curlpp](http://www.curlpp.org/) (tested: 0.8)
|
||||||
echo "instance=social.example.com" >> ~/.config/feiertagebot.cfg
|
* [jsoncpp](https://github.com/open-source-parsers/jsoncpp) (tested: 1.8)
|
||||||
./feiertagebot
|
|
||||||
----
|
|
||||||
|
|
||||||
== Lizenz
|
== Lizenz
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,56 @@
|
||||||
// Author: tastytea <tastytea@tastytea.de>
|
// Author: tastytea <tastytea@tastytea.de>
|
||||||
// CC-0 / Public Domain
|
// CC-0 / Public Domain
|
||||||
// Version: 2019-02-11_1
|
|
||||||
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <curlpp/Options.hpp>
|
||||||
|
#include <curlpp/Exception.hpp>
|
||||||
|
#include <curlpp/Infos.hpp>
|
||||||
|
#include <json/json.h>
|
||||||
|
|
||||||
|
namespace curlopts = curlpp::options;
|
||||||
|
using std::string;
|
||||||
|
using std::cout;
|
||||||
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
const string version = "2019-02-11_1";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string year = "2019";
|
||||||
|
string today = "2019-12-25";
|
||||||
|
string tomorrow = "2019-12-26";
|
||||||
|
curlpp::Easy request;
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
request.setOpt<curlopts::Url>("https://feiertage-api.de/api/?jahr=" + year);
|
||||||
|
request.setOpt<curlopts::UserAgent>("feiertagebot/" + version);
|
||||||
|
request.setOpt<curlopts::FollowLocation>(true);
|
||||||
|
ss << request;
|
||||||
|
|
||||||
|
Json::Value root;
|
||||||
|
ss >> root;
|
||||||
|
|
||||||
|
for (Json::Value::const_iterator it_root = root.begin(); it_root != root.end(); ++it_root)
|
||||||
|
{
|
||||||
|
for (Json::Value::const_iterator it_region = it_root->begin(); it_region != it_root->end(); ++it_region)
|
||||||
|
{
|
||||||
|
if ((*it_region)["datum"] == today)
|
||||||
|
{
|
||||||
|
cout << it_root.key() << ": " << (*it_region)["datum"] << ": " << it_region.key() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
cerr << e.what() << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue