diff --git a/CMakeLists.txt b/CMakeLists.txt
index d742795..9a9ab89 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.7)
include(GNUInstallDirs)
project (rss2mastodon
- VERSION 0.1.6
+ VERSION 0.1.7
LANGUAGES CXX
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall")
diff --git a/README.md b/README.md
index 72b558e..efeaeba 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
**rss2mastodon** dumps RSS feeds into a mastodon account.
+It is hacked together and generally only extended/fixed when it fails.
+Use at your own risk.
# Install
diff --git a/src/rss2mastodon.cpp b/src/rss2mastodon.cpp
index a79a9e5..6962877 100644
--- a/src/rss2mastodon.cpp
+++ b/src/rss2mastodon.cpp
@@ -37,6 +37,7 @@ using std::cout;
using std::cerr;
using std::string;
+uint16_t max_size = 500;
const string filepath = string(getenv("HOME")) + "/.config/rss2mastodon/";
void read_config(pt::ptree &config, const string &profile, string &instance, string &access_token, string &feedurl)
@@ -53,7 +54,7 @@ void read_config(pt::ptree &config, const string &profile, string &instance, str
catch (std::exception &e)
{
// most likely no config file found
- cout << "No config file found. Building new one.\n";
+ cout << "Config file not readable. Building new one.\n";
const boost::filesystem::path path(filepath);
boost::filesystem::create_directory(filepath);
}
@@ -141,13 +142,35 @@ std::vector
");
+ std::regex recdata1("");
+ std::regex restrip("<[^>]*>");
+ std::regex reindyfuckup("\\/\\* Style Definitions \\*\\/[.[:space:]]*$");
+
+ str = std::regex_replace(str, relt, "<");
+ str = std::regex_replace(str, regt, ">");
+ str = std::regex_replace(str, reparagraph, "\n\n");
+ str = std::regex_replace(str, recdata1, "");
+ str = std::regex_replace(str, recdata2, "");
+ str = std::regex_replace(str, restrip, "");
+ str = std::regex_replace(str, reindyfuckup, "");
+
for (const string &hashtag : watchwords)
{
- std::regex rehashtag("[[:space:][:punct:]](" + hashtag + ")[[:space:][:punct:]]",
+ std::regex rehashtag("([[:space:][:punct:]^])(" + hashtag + ")([[:space:][:punct:]$])",
std::regex_constants::icase);
- str = std::regex_replace(str, rehashtag, "#$1",
+ str = std::regex_replace(str, rehashtag, "$1#$2$3",
std::regex_constants::format_first_only);
}
+ if ((str.size() + link.size()) > (max_size - 15))
+ {
+ str.resize((max_size - link.size() - 15));
+ str += " […]";
+ }
str += "\n\n" + link + "\n\n#bot";
ret.push_back(str);
}
@@ -161,15 +184,21 @@ int main(int argc, char *argv[])
{
if (argc < 2)
{
- cerr << "usage: " << argv[0] << "