tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
BotCommand.hpp
Go to the documentation of this file.
1#pragma once
2#include <string>
4
5namespace tgbotxx {
8 struct BotCommand {
9 BotCommand() = default;
10 explicit BotCommand(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::string command;
16
18 std::string description;
19
20 nl::json toJson() const {
21 nl::json cmd = nl::json::object();
22 OBJECT_SERIALIZE_FIELD(cmd, "command", command);
23 OBJECT_SERIALIZE_FIELD(cmd, "description", description);
24 return cmd;
25 }
26
27 void fromJson(const nl::json& json) {
28 OBJECT_DESERIALIZE_FIELD(json, "command", command, "", false);
29 OBJECT_DESERIALIZE_FIELD(json, "description", description, "", false);
30 }
31 };
32}
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:44
This object represents a bot command. https://core.telegram.org/bots/api#botcommand.
Definition BotCommand.hpp:8
void fromJson(const nl::json &json)
std::string description
Description of the command; 1-256 characters.
nl::json toJson() const
std::string command
Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and undersco...
BotCommand(const nl::json &json)