From a37605e3d7d17e322a9cf2a497768f6fd8b5d0a3 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 7 Dec 2023 16:14:14 -0500 Subject: Fix lingobot breaking out of its cage --- lingo.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lingo.cpp b/lingo.cpp index fde9383..afa7a4c 100644 --- a/lingo.cpp +++ b/lingo.cpp @@ -979,13 +979,19 @@ private: std::string solution = cached_puzzle_->solution; bot_->message_create(message, [this, solution](const dpp::confirmation_callback_t& userdata) { - const auto& posted_msg = std::get(userdata.value); - std::lock_guard answer_lock(answers_mutex_); - if (answer_by_message_.size() > 3000) - { - answer_by_message_.clear(); + if (!userdata.is_error()) { + const auto& posted_msg = std::get(userdata.value); + std::lock_guard answer_lock(answers_mutex_); + if (answer_by_message_.size() > 3000) + { + answer_by_message_.clear(); + } + if (posted_msg.id != 0) { + answer_by_message_[posted_msg.id] = solution; + } + } else { + std::cout << "Error posting message: " << userdata.get_error().message << std::endl; } - answer_by_message_[posted_msg.id] = solution; }); #endif -- cgit 1.4.1