diff --git a/CMakeLists.txt b/CMakeLists.txt index 4045451..9ac6b63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastorss - VERSION 0.3.1 + VERSION 0.3.2 LANGUAGES CXX ) diff --git a/README.md b/README.md index ee8f3b1..75a00c0 100644 --- a/README.md +++ b/README.md @@ -43,16 +43,22 @@ In the first run only the newest entry is tooted. The profile can't be named "global". +## Example config file + + { + "example": { + "instance": "botsin.space", + "feedurl": "https:\/\/example.com\/feed.rss", + "access_token": "123abc", + "max_size": "400", + "last_entry": "Example\n\nThis is an example.\n\nhttps:\/\/example.com\/12345.html\n\n#bot" + } + } + + ## Error codes -| Code | Explanation | -| --------: |:------------------------------| -| 0 | No error | -| 1 | Invalid call | -| 2 | Not implemented | -| 10 | Wrong number of arguments | -| 100 - 999 | HTTP status codes | -| 65535 | Unknown exception | +Same as [mastodon-cpp](https://github.com/tastytea/mastodon-cpp/blob/master/README.md#error-codes) If you use a debug build, you get more verbose error messages. diff --git a/src/config.cpp b/src/config.cpp index 9e1269a..5ef16af 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -41,6 +41,7 @@ std::uint16_t read_config(pt::ptree &config, const string &profile, string &inst instance = config.get(profile + ".instance", ""); access_token = config.get(profile + ".access_token", ""); feedurl = config.get(profile + ".feedurl", ""); + max_size = config.get(profile + ".max_size", max_size); } catch (std::exception &e) { diff --git a/src/parse.cpp b/src/parse.cpp index 543a12e..de8ed4d 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -53,8 +53,15 @@ void unescape_html(string &str) std::regex relt("<"); std::regex regt(">"); + std::regex reamp("&"); + std::regex requot("""); + std::regex reapos("'"); + str = std::regex_replace(str, relt, "<"); str = std::regex_replace(str, regt, ">"); + str = std::regex_replace(str, reamp, "&"); + str = std::regex_replace(str, requot, "\""); + str = std::regex_replace(str, reapos, "\'"); } std::vector parse_website(const string &profile, const string &xml) @@ -140,7 +147,7 @@ std::vector parse_website(const string &profile, const string &xml) str = std::regex_replace(str, reindyfuckup, ""); str = std::regex_replace(str, redaclosing, ""); str = std::regex_replace(str, reggboclosing, ""); - str = std::regex_replace(str, std::regex("[\\n\\r]{3,}"), "\n"); // remove excess newlines + str = std::regex_replace(str, std::regex("[\\n\\r ]{3,}"), "\n"); // remove excess newlines for (const string &hashtag : watchwords) {