From e9e16f96d8ca4d9e73b06594efbe715f0b80a616 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 11 May 2018 07:24:03 +0200 Subject: [PATCH] Check if there are URLs in that message --- CMakeLists.txt | 2 +- README.md | 2 +- src/main.cpp | 18 ++++++++++++++---- src/masto.cpp | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e10af0..e604cd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (expandurl-mastodon - VERSION 0.1.0 + VERSION 0.1.1 LANGUAGES CXX ) diff --git a/README.md b/README.md index 1edb07e..4dbb778 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ mention the bot account (@expandurl@botsin.space for example). * C++ compiler (tested: gcc 6.4, clang 5.0) * [cmake](https://cmake.org/) (tested: 3.9.6) * [curlpp](http://www.curlpp.org/) (tested: 0.8.4) - * [mastodon-cpp](https://github.com/tastytea/mastodon-cpp) (at least: 0.12.0) + * [mastodon-cpp](https://github.com/tastytea/mastodon-cpp) (at least: 0.12.1) ## Get sourcecode diff --git a/src/main.cpp b/src/main.cpp index 6165367..e8331f2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -95,14 +95,24 @@ int main(int argc, char *argv[]) { message += url + " \n"; } - if (listener.send_reply(notif.status(), message)) + if (!message.empty()) { - cout << "Sent reply: " << message; + message = '@' + notif.status().account().acct() + + ' ' + message; + if (listener.send_reply(notif.status(), message)) + { + cout << "Sent reply: " << message; + } + else + { + cerr << "ERROR: could not send reply to " << + notif.status().id() << '\n'; + } } else { - cerr << "ERROR: could not send reply to " << - notif.status().id() << '\n'; + listener.send_reply(notif.status(), + "I couldn't find an URL in the message you replied to. 😞"); } } } diff --git a/src/masto.cpp b/src/masto.cpp index 8f205d6..fe5ee65 100644 --- a/src/masto.cpp +++ b/src/masto.cpp @@ -131,7 +131,7 @@ const bool Listener::send_reply(const Easy::Status &status, { { "in_reply_to_id", { id } }, { "visibility", { strvisibility } }, - { "status", { '@' + status.account().acct() + ' ' + message } } + { "status", { message } } }; if (status.sensitive())