mirror of
https://github.com/PaiGramTeam/telegram-bot-api.git
synced 2024-11-25 09:37:37 +00:00
Support CopyText inline buttons.
This commit is contained in:
parent
a17922555e
commit
a9a3e7ba21
@ -2593,6 +2593,19 @@ class Client::JsonWebAppInfo final : public td::Jsonable {
|
||||
const td::string &url_;
|
||||
};
|
||||
|
||||
class Client::JsonCopyTextButton final : public td::Jsonable {
|
||||
public:
|
||||
explicit JsonCopyTextButton(const td::string &text) : text_(text) {
|
||||
}
|
||||
void store(td::JsonValueScope *scope) const {
|
||||
auto object = scope->enter_object();
|
||||
object("text", text_);
|
||||
}
|
||||
|
||||
private:
|
||||
const td::string &text_;
|
||||
};
|
||||
|
||||
class Client::JsonInlineKeyboardButton final : public td::Jsonable {
|
||||
public:
|
||||
explicit JsonInlineKeyboardButton(const td_api::inlineKeyboardButton *button) : button_(button) {
|
||||
@ -2664,8 +2677,11 @@ class Client::JsonInlineKeyboardButton final : public td::Jsonable {
|
||||
object("web_app", JsonWebAppInfo(type->url_));
|
||||
break;
|
||||
}
|
||||
case td_api::inlineKeyboardButtonTypeCopyText::ID:
|
||||
case td_api::inlineKeyboardButtonTypeCopyText::ID: {
|
||||
auto type = static_cast<const td_api::inlineKeyboardButtonTypeCopyText *>(button_->type_.get());
|
||||
object("copy_text", JsonCopyTextButton(type->text_));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
@ -7747,6 +7763,14 @@ td::Result<td_api::object_ptr<td_api::inlineKeyboardButton>> Client::get_inline_
|
||||
return make_object<td_api::inlineKeyboardButton>(text, make_object<td_api::inlineKeyboardButtonTypeWebApp>(url));
|
||||
}
|
||||
|
||||
if (object.has_field("copy_text")) {
|
||||
TRY_RESULT(copy_text, object.extract_required_field("copy_text", td::JsonValue::Type::Object));
|
||||
auto ©_text_object = copy_text.get_object();
|
||||
TRY_RESULT(copied_text, copy_text_object.get_required_string_field("text"));
|
||||
return make_object<td_api::inlineKeyboardButton>(
|
||||
text, make_object<td_api::inlineKeyboardButtonTypeCopyText>(copied_text));
|
||||
}
|
||||
|
||||
return td::Status::Error(400, "Text buttons are unallowed in the inline keyboard");
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,7 @@ class Client final : public WebhookActor::Callback {
|
||||
class JsonEntity;
|
||||
class JsonVectorEntities;
|
||||
class JsonWebAppInfo;
|
||||
class JsonCopyTextButton;
|
||||
class JsonInlineKeyboardButton;
|
||||
class JsonInlineKeyboard;
|
||||
class JsonReplyMarkup;
|
||||
|
Loading…
Reference in New Issue
Block a user