feat(plugins): Added message read/update methods to the Channel API. (#6650)

This PR adds methods to read and update messages in a channel. Specifically, it adds:
 - message_snapshot
 - last_message
 - replace_message/replace_message_at
 - clear_messages
 - find_message_by_id
 - has_messages
 - count_messages


Reviewed-by: Mm2PL <mm2pl+gh@kotmisia.pl>
This commit is contained in:
Nerixyz
2026-01-21 00:46:39 +01:00
committed by GitHub
parent 281d5be3fd
commit d21b3c6e38
12 changed files with 498 additions and 1 deletions
+20
View File
@@ -56,6 +56,14 @@ public:
return this->buffer_.empty();
}
/// Number of items in this container
[[nodiscard]] size_t size() const
{
std::shared_lock lock(this->mutex_);
return this->buffer_.size();
}
/// Value Accessors
// Copies of values are returned so that references aren't invalidated
@@ -335,6 +343,18 @@ public:
};
}
template <typename U>
[[nodiscard]] std::vector<U> lastNBy(size_t nItems, auto &&cb) const
{
std::shared_lock lock(this->mutex_);
std::vector<U> vec;
std::transform(
this->buffer_.end() - std::min(nItems, this->buffer_.size()),
this->buffer_.end(), std::back_inserter(vec),
std::forward<decltype(cb)>(cb));
return vec;
}
[[nodiscard]] std::vector<T> firstN(size_t nItems) const
{
std::shared_lock lock(this->mutex_);