#include "commands.h" #include "td/telegram/td_api.h" #include #include #include #include void cmd::handle_regular_message(context *ctx, td_api::message &msg) { if (msg.content_->get_id() == td_api::messageText::ID) { std::string text = static_cast(*msg.content_).text_->text_; if (std::strncmp(text.c_str(), "/shorten ", 9) == 0) { std::string_view param(text.begin() + 9, text.end()); size_t nextSpace = param.find(' '); if (nextSpace != std::string_view::npos) param.remove_suffix(param.size() - nextSpace); spdlog::info("Command /shorten received with parameter '{}'", param); } else if (std::strncmp(text.c_str(), "/shorten", 8) == 0) { std::string textRaw("usage: /shorten "); std::vector> empty; auto text = static_cast>(td_api::make_object(td_api::make_object(textRaw, std::move(empty)), nullptr, false)); ctx->tg->send_query(td_api::make_object(msg.chat_id_, msg.message_thread_id_, nullptr, nullptr, nullptr, std::move(text)), {}); } } }