流程结束,退出代码为11

时间:2019-12-22 15:46:02

标签: c++ tdlib

当我将多个函数添加到地图矢量时,我正在制作tdlib包装程序,并且应用程序关闭。有人可以帮助您找到问题吗?

我的第一个猜测是该脚本使process_messages函数崩溃,但我不知道为什么。

    typedef void(*voidfuncptr)(td_api::updateNewMessage);

    std::map<std::string, voidfuncptr> message_handlers_;
    std::map<std::string, bool> outgoing_;


    void add_message_handler(voidfuncptr ptr, const std::string& pattern, bool outgoing){
        message_handlers_[pattern]=ptr;
        outgoing_[pattern] = outgoing;
    }

    void process_messages(td_api::updateNewMessage &update_new_message){
        auto text = static_cast<td_api::messageText &>(*update_new_message.message_->content_).text_->text_;
        bool is_outgoing_ = update_new_message.message_->is_outgoing_;
        for (auto const &ent1 : message_handlers_){
            std::regex pattern_(ent1.first);
            bool out = outgoing_[ent1.first]
            auto message_ok_ = message_ok(pattern_, out, update_new_message);
            if (message_ok_){
                voidfuncptr f = message_handlers_[ent1.first];
                f(std::move(update_new_message));
            }

        }
    }


    bool message_ok(std::regex pattern, bool outgoing, td_api::updateNewMessage &update_new_message){
        auto text = static_cast<td_api::messageText &>(*update_new_message.message_->content_).text_->text_;
        bool pattern_ = std::regex_match(text, pattern);
        bool outgoing_ = update_new_message.message_->is_outgoing_;
        if (outgoing_ == outgoing){
            return true;
        }
        if (outgoing == true){
            if (outgoing_){
                if (pattern_){
                    return true;
                } else{
                    return false;}
            }
        }

0 个答案:

没有答案