yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
sendVoice.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <optional>
4 #include "methods/sendVoice.h"
5 
6 using namespace std;
7 using namespace yatbcpp;
8 
10 // Constructor Section //
12 
13 sendVoice::sendVoice(Chat C, string voice) :
14  telegram_methodJSON("sendVoice"), telegram_methodMultipart("sendVoice"),
15  chat_id(to_string(C.getId())), voice(move(voice))
16 {
17 
18 }
19 
20 sendVoice::sendVoice(int64_t chat_id, string voice) :
21  telegram_methodJSON("sendVoice"), telegram_methodMultipart("sendVoice"),
22  chat_id(to_string(chat_id)), voice(move(voice))
23 {
24 
25 }
26 
27 sendVoice::sendVoice(string chat_id, string voice) :
28  telegram_methodJSON("sendVoice"), telegram_methodMultipart("sendVoice"),
29  chat_id(move(chat_id)), voice(move(voice))
30 {
31 
32 }
33 
35 // Outgoing Section //
37 
38 
39 Json::Value sendVoice::toJson() {
40  Json::Value Outgoing;
41  Outgoing["chat_id"] = getChat_id();
42  Outgoing["voice"] = getVoice();
43 
44  if(getCaption()){
45  Outgoing["caption"] = getCaption().value();
46  }
47  if(getDuration()){
48  Outgoing["duration"] = getDuration().value();
49  }
51  Outgoing["disable_notification"] = getDisable_notification().value();
52  }
54  Outgoing["reply_to_message_id"] = getReply_to_message_id().value();
55  }
56 
57  return Outgoing;
58 
59 }
60 
61 void sendVoice::add_to_post(struct curl_httppost **start, struct curl_httppost **end) {
62  curl_formadd(start,end,
63  CURLFORM_COPYNAME,"chat_id",
64  CURLFORM_COPYCONTENTS,chat_id.c_str(),
65  CURLFORM_END);
66  curl_formadd(start,end,
67  CURLFORM_COPYNAME,"voice",
68  CURLFORM_FILE,voice.c_str(),
69  CURLFORM_END);
70  if(caption){
71  curl_formadd(start,end,
72  CURLFORM_COPYNAME,"caption",
73  CURLFORM_COPYCONTENTS,caption.value().c_str(),
74  CURLFORM_END);
75  }
76 }
77 
79 // Setter Section //
81 
82 void sendVoice::setCaption(const optional<string> &caption) {
84 }
85 
86 
87 void sendVoice::setDuration(const optional<unsigned int> &duration) {
89 }
90 
93 }
94 
97 }
98 
105 }
106 
113 }
114 
121 }
122 
124 // Getter Section //
126 
127 const string &sendVoice::getChat_id() const {
128  return chat_id;
129 }
130 
131 const string &sendVoice::getVoice() const {
132  return voice;
133 }
134 
135 const optional<string> &sendVoice::getCaption() const {
136  return caption;
137 }
138 
139 const optional<unsigned int> &sendVoice::getDuration() const {
140  return duration;
141 }
142 
143 const optional<bool> &sendVoice::getDisable_notification() const {
144  return disable_notification;
145 }
146 
147 const optional<int32_t> &sendVoice::getReply_to_message_id() const {
148  return reply_to_message_id;
149 }
150 
151 const optional<ReplyMarkup> &sendVoice::getReply_markup() const {
152  return reply_markup;
153 }
std::optional< bool > disable_notification
Definition: sendVideo.h:90
Json::Value toJson()
Definition: sendVoice.cc:39
std::optional< unsigned int > duration
Definition: sendVoice.h:79
const std::optional< std::int32_t > & getReply_to_message_id() const
Definition: sendVideo.cc:169
const std::optional< bool > & getDisable_notification() const
Definition: sendVoice.cc:143
const std::optional< int > & getReply_to_message_id() const
Definition: sendVoice.cc:147
void setReply_to_message_id(const std::optional< int > &reply_to_message_id)
Definition: sendVoice.cc:95
const std::optional< std::string > & getCaption() const
Definition: sendVideo.cc:149
void setDuration(const std::optional< unsigned int > &duration)
Definition: sendVoice.cc:87
void setCaption(const std::optional< std::string > &caption)
Definition: sendVoice.cc:82
const std::optional< std::string > & getCaption() const
Definition: sendVoice.cc:135
std::string chat_id
Definition: sendVideo.h:84
void setReplyMarkup(const ReplyKeyboardMarkup RKM)
Definition: sendVoice.cc:103
std::optional< std::string > caption
Definition: sendVideo.h:86
const std::string & getChat_id() const
Definition: sendVideo.cc:141
std::optional< bool > disable_notification
Definition: sendVoice.h:80
const std::string & getChat_id() const
Definition: sendVoice.cc:127
Definition: Bot.h:27
const std::optional< bool > & getDisable_notification() const
Definition: sendVideo.cc:165
const std::optional< unsigned int > & getDuration() const
Definition: sendVoice.cc:139
std::optional< ReplyMarkup > reply_markup
Definition: sendVideo.h:92
void setDisable_notification(const std::optional< bool > &disable_notification)
Definition: sendVoice.cc:91
const std::optional< ReplyMarkup > & getReply_markup() const
Definition: sendVoice.cc:151
std::optional< ReplyMarkup > reply_markup
Definition: sendVoice.h:82
sendVoice(std::int64_t chat_id, std::string voice)
const std::string & getVoice() const
Definition: sendVoice.cc:131
const std::optional< unsigned int > & getDuration() const
Definition: sendVideo.cc:153
void add_to_post(struct curl_httppost **start, struct curl_httppost **end)
Definition: sendVoice.cc:61
std::optional< int > reply_to_message_id
Definition: sendVoice.h:81
std::optional< unsigned int > duration
Definition: sendVideo.h:87
std::optional< std::string > caption
Definition: sendVoice.h:78
std::optional< std::int32_t > reply_to_message_id
Definition: sendVideo.h:91