diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-12-07 16:14:14 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-12-07 16:14:14 -0500 |
commit | a37605e3d7d17e322a9cf2a497768f6fd8b5d0a3 (patch) | |
tree | d1877e01e115eab3f28142bfa1724daca387683c | |
parent | 87f48c963423f26d04791bc402bd45fb8dbbdb46 (diff) | |
download | lingo-a37605e3d7d17e322a9cf2a497768f6fd8b5d0a3.tar.gz lingo-a37605e3d7d17e322a9cf2a497768f6fd8b5d0a3.tar.bz2 lingo-a37605e3d7d17e322a9cf2a497768f6fd8b5d0a3.zip |
Fix lingobot breaking out of its cage
-rw-r--r-- | lingo.cpp | 18 |
1 files 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: | |||
979 | 979 | ||
980 | std::string solution = cached_puzzle_->solution; | 980 | std::string solution = cached_puzzle_->solution; |
981 | bot_->message_create(message, [this, solution](const dpp::confirmation_callback_t& userdata) { | 981 | bot_->message_create(message, [this, solution](const dpp::confirmation_callback_t& userdata) { |
982 | const auto& posted_msg = std::get<dpp::message>(userdata.value); | 982 | if (!userdata.is_error()) { |
983 | std::lock_guard answer_lock(answers_mutex_); | 983 | const auto& posted_msg = std::get<dpp::message>(userdata.value); |
984 | if (answer_by_message_.size() > 3000) | 984 | std::lock_guard answer_lock(answers_mutex_); |
985 | { | 985 | if (answer_by_message_.size() > 3000) |
986 | answer_by_message_.clear(); | 986 | { |
987 | answer_by_message_.clear(); | ||
988 | } | ||
989 | if (posted_msg.id != 0) { | ||
990 | answer_by_message_[posted_msg.id] = solution; | ||
991 | } | ||
992 | } else { | ||
993 | std::cout << "Error posting message: " << userdata.get_error().message << std::endl; | ||
987 | } | 994 | } |
988 | answer_by_message_[posted_msg.id] = solution; | ||
989 | }); | 995 | }); |
990 | #endif | 996 | #endif |
991 | 997 | ||