From e312f062a52e782c188e21d007c4f856396e5cfe Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 11 May 2018 01:17:53 +0200 Subject: [PATCH] Made the appended string configurable --- CMakeLists.txt | 2 +- README.md | 3 ++- src/config.cpp | 8 ++++++++ src/mastorss.hpp | 1 - src/parse.cpp | 8 +++++++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e28c5d..7bb29e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastorss - VERSION 0.5.17 + VERSION 0.6.0 LANGUAGES CXX ) diff --git a/README.md b/README.md index 038203a..9385253 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,8 @@ ${HOME}/.config/mastorss/config-example.json [ "delete this", "[Rr]ead more(\.{3}|…)" - ] + ], + "append": "#bot" } } diff --git a/src/config.cpp b/src/config.cpp index 08dcdf7..ca03c6d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -133,6 +133,14 @@ std::uint16_t read_config(string &instance, string &access_token, string &feedur } config_changed = true; } + if (config[profile]["append"].isNull()) + { + string append; + cout << "Append this string to each post []: "; + cin >> append; + config[profile]["append"] = append; + config_changed = true; + } if (config_changed) { write_config(); diff --git a/src/mastorss.hpp b/src/mastorss.hpp index fab9cf7..7f21b0a 100644 --- a/src/mastorss.hpp +++ b/src/mastorss.hpp @@ -17,7 +17,6 @@ std::uint16_t read_config(string &instance, string &access_token, string &feedur const bool write_config(); std::vector parse_website(const string &xml); -void unescape_html(const string &str); void individual_fixes(string &str); const std::uint16_t http_get(const string &feedurl, diff --git a/src/parse.cpp b/src/parse.cpp index eb53218..0836c36 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -158,7 +158,13 @@ std::vector parse_website(const string &xml) { str.resize(str.length() - 1); } - str += "\n\n" + link + "\n\n#bot"; + + str += "\n\n" + link; + + if (!config[profile]["append"].empty()) + { + str += "\n\n" + config[profile]["append"].asString(); + } ret.push_back(str); } }