summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Giove <andreagiove@outlook.com>2016-04-17 22:09:52 +0200
committerAndrea Giove <andreagiove@outlook.com>2016-04-17 22:09:52 +0200
commit9ba69d7e87c9b8ff9997294b68550852ef0274b8 (patch)
tree901f2ddc98f63cb96163277a4bc55eb5812f9186 /src
parentd134bf795a293a641655630bdd8ad44b5b70c1ae (diff)
Added new type: Venue, MessageEntity
Update Message type Added new method: sendVenue, sendContact, kickChatMember, unbanChatMember
Diffstat (limited to 'src')
-rw-r--r--src/Api.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Api.cpp b/src/Api.cpp
index 3ae582c..55c0320 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -307,6 +307,46 @@ Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude,
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendLocation", args));
}
+Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, std::string title, std::string address, std::string foursquareId, bool disableNotification, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("latitude", latitude));
+ args.push_back(HttpReqArg("longitude", longitude));
+ args.push_back(HttpReqArg("title", title));
+ args.push_back(HttpReqArg("address", address));
+ if (!foursquareId.empty()) {
+ args.push_back(HttpReqArg("foursquare_id", foursquareId));
+ }
+ if (replyToMessageId) {
+ args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId));
+ }
+ if (replyMarkup) {
+ args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
+ }
+ if (disableNotification){
+ args.push_back(HttpReqArg("disable_notification", disableNotification));
+ }
+ return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVenue", args));
+}
+
+Message::Ptr Api::sendContact(int64_t chatId, std::string phoneNumber, std::string firstName, std::string lastName, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr& replyMarkup) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("phone_number", phoneNumber));
+ args.push_back(HttpReqArg("first_name", firstName));
+ args.push_back(HttpReqArg("last_name", lastName));
+ if (replyToMessageId) {
+ args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId));
+ }
+ if (replyMarkup) {
+ args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
+ }
+ if (disableNotification){
+ args.push_back(HttpReqArg("disable_notification", disableNotification));
+ }
+ return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendContact", args));
+}
+
void Api::sendChatAction(int64_t chatId, const string& action) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
@@ -360,6 +400,20 @@ void Api::answerInlineQuery(const std::string& inlineQueryId, const std::vector<
sendRequest("answerInlineQuery", args);
}
+void Api::kickChatMember(int64_t chatId, int32_t userId) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("user_id", userId));
+ sendRequest("kickChatMember", args);
+}
+
+void Api::unbanChatMember(int64_t chatId, int32_t userId) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("user_id", userId));
+ sendRequest("unbanChatMember", args);
+}
+
ptree Api::sendRequest(const string& method, const vector<HttpReqArg>& args) const {
string url = "https://api.telegram.org/bot";