cyanray / mirai-cpp

本项目为 mirai-api-http 的 C++ 封装,方便使用 C++ 开发基于 mirai-api-http 插件。
GNU Affero General Public License v3.0
148 stars 38 forks source link

Is there any reason change the return type of AtMe from book to void? #107

Closed Slontia closed 3 years ago

Slontia commented 3 years ago

My code is using AtMe to check whether the bot is at by other qq users. But when I updated the mirai-cpp code to the latest version, my code compiled failed because the return type has been changed to void.

How can I achieve the above propose with the latest code?

        void GroupMessage::AtMe() const
    {
        auto at = MessageChain.GetAll<AtMessage>();
        auto it = std::find_if(at.begin(), at.end(), [&](AtMessage a) {return a.Target() == bot_->GetBotQQ(); });
        if (it != at.end()) return;
        else return;
    }
cyanray commented 3 years ago

😂This is a mistake, I've fixed it.

bool GroupMessage::AtMe() const
{
    auto at = MessageChain.GetAll<AtMessage>();
    auto it = std::find_if(at.begin(), at.end(), [&](const AtMessage& a) { return a.Target() == bot_->GetBotQQ(); });
    return it != at.end();
}