tgbotxx  1.1.6.9
Telegram Bot C++ Library
BotCommand.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <string>
4 
5 namespace 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
Definition: Api.hpp:14
This object represents a bot command. https://core.telegram.org/bots/api#botcommand.
Definition: BotCommand.hpp:8
void fromJson(const nl::json &json)
Definition: BotCommand.hpp:27
std::string description
Description of the command; 1-256 characters.
Definition: BotCommand.hpp:18
nl::json toJson() const
Definition: BotCommand.hpp:20
std::string command
Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and undersco...
Definition: BotCommand.hpp:15
BotCommand(const nl::json &json)
Definition: BotCommand.hpp:10