From 63b11121bbeb4b97fd9099afcf2106a8a7ee6619 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 26 Jan 2018 20:59:01 +0100 Subject: [PATCH] toot newest entry on first run --- CMakeLists.txt | 2 +- README.md | 5 +++-- src/rss2mastodon.cpp | 10 +++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42187d7..3477071 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.7) include(GNUInstallDirs) project (rss2mastodon - VERSION 0.1.2 + VERSION 0.1.3 LANGUAGES CXX ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall") diff --git a/README.md b/README.md index 0482032..72b558e 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,9 @@ Install with `make install`. # Usage Put watchwords.json into `~/.config/rss2mastodon/`. Launch with profile name. -In the first run nothing is tooted, only the newest entry is saved. -In the next run only newer entries are tooted. +In the first run only the newest entry is tooted. + +The profile can't be named "global". ## Error codes diff --git a/src/rss2mastodon.cpp b/src/rss2mastodon.cpp index deee8ef..77ea201 100644 --- a/src/rss2mastodon.cpp +++ b/src/rss2mastodon.cpp @@ -181,7 +181,15 @@ int main(int argc, char *argv[]) http_get(hostname, path, answer); entries = parse_website(profile, answer); - config.put(profile + ".last_entry", entries.front()); + if (last_entry.empty()) + { + last_entry = entries.at(1); + config.put(profile + ".last_entry", last_entry); + } + else + { + config.put(profile + ".last_entry", entries.front()); + } pt::write_json(filepath + "config.json", config); bool new_content = false;