Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

fix: MessageChain.h #191

Merged
merged 1 commit into from
Mar 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cpp/include/sdk/MessageChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace MiraiCP {
/// 筛选出某种类型的消息
/// @note 最多可能将整个vector复制一次
template<typename T>
std::vector<T> filter() {
std::vector<T> filter() const {
static_assert(std::is_base_of_v<SingleMessage, T>, "只支持SingleMessage的子类");
std::vector<T> re;
for (auto &&a: *this) {
Expand All @@ -161,7 +161,7 @@ namespace MiraiCP {
/// 自定义筛选器
/// @note 最多可能将整个vector复制一次
template<typename T>
std::vector<T> filter(const std::function<bool(const Message &)> &func) {
std::vector<T> filter(const std::function<bool(const Message &)> &func) const {
static_assert(std::is_base_of_v<SingleMessage, T>, "只支持SingleMessage的子类");
std::vector<T> re;
for (auto &&a: *this) {
Expand All @@ -173,7 +173,7 @@ namespace MiraiCP {

/// 找出第一个指定的type的消息,消息可能不存在
template<typename T>
std::optional<T> first() {
std::optional<T> first() const {
for (auto &&a: *this)
if (a.getType() == T::type())
return a.getVal<T>();
Expand Down