summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rw-r--r--Dockerfile_test7
-rw-r--r--Doxyfile86
-rw-r--r--README.md2
-rw-r--r--include/tgbot/Api.h50
-rw-r--r--include/tgbot/TgTypeParser.h13
-rw-r--r--include/tgbot/types/Chat.h7
-rw-r--r--include/tgbot/types/ChatMember.h10
-rw-r--r--include/tgbot/types/ChatPermissions.h86
-rw-r--r--include/tgbot/types/InlineKeyboardButton.h6
-rw-r--r--include/tgbot/types/LoginUrl.h45
-rw-r--r--include/tgbot/types/Message.h17
-rw-r--r--include/tgbot/types/Poll.h63
-rw-r--r--include/tgbot/types/PollOption.h50
-rw-r--r--include/tgbot/types/Sticker.h5
-rw-r--r--include/tgbot/types/StickerSet.h5
-rw-r--r--src/Api.cpp67
-rw-r--r--src/TgTypeParser.cpp89
18 files changed, 538 insertions, 80 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d05c9b..1759746 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,15 +1,14 @@
cmake_minimum_required(VERSION 2.8.4)
project(TgBot)
-set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
-
# options
option(ENABLE_TESTS "Set to ON to enable building of tests" OFF)
option(BUILD_SHARED_LIBS "Build tgbot-cpp shared/static library." OFF)
# sources
if(WIN32)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Do not activate all warnings in VS (too much output for Appveyor)
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
endif()
@@ -28,14 +27,13 @@ set(SRC_LIST
src/tools/FileTools.cpp
src/tools/StringTools.cpp
src/types/InlineQueryResult.cpp
- src/types/InputFile.cpp
-)
+ src/types/InputFile.cpp)
# libs
## threads
find_package(Threads REQUIRED)
-# zlib
+## zlib
find_package(ZLIB REQUIRED)
## openssl
diff --git a/Dockerfile_test b/Dockerfile_test
index 9ff0764..656e67f 100644
--- a/Dockerfile_test
+++ b/Dockerfile_test
@@ -1,11 +1,8 @@
-FROM ubuntu:14.04
+FROM debian:stretch
MAINTAINER Oleg Morozenkov <a@reo7sp.ru>
RUN apt-get -qq update && \
- apt-get -qq install -y g++ make binutils cmake libssl-dev libcurl4-openssl-dev
-
-RUN apt-get -qq update && \
- apt-get -qq install -y wget build-essential python-dev autotools-dev libicu-dev libbz2-dev zlib1g-dev
+ apt-get -qq install -y g++ make binutils cmake libssl-dev libcurl4-openssl-dev wget build-essential python-dev autotools-dev libicu-dev libbz2-dev zlib1g-dev
WORKDIR /usr/src/boost
RUN wget -q -O boost_1_59_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download && \
diff --git a/Doxyfile b/Doxyfile
index ae557e7..2b036f8 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -63,7 +63,7 @@ OUTPUT_DIRECTORY = doc
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
# will distribute the generated files over these directories. Enabling this
-# option can be useful when feeding doxygen a huge amount of source files, where
+# options can be useful when feeding doxygen a huge amount of source files, where
# putting all generated files in the same directory would otherwise causes
# performance problems for the file system.
# The default value is: NO.
@@ -330,7 +330,7 @@ AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# If you use Microsoft's C++/CLI language, you should set this options to YES to
# enable parsing support.
# The default value is: NO.
@@ -345,11 +345,11 @@ CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
# For Microsoft's IDL there are propget and propput attributes to indicate
-# getter and setter methods for a property. Setting this option to YES will make
+# getter and setter methods for a property. Setting this options to YES will make
# doxygen to replace the get and set methods by a property in the documentation.
# This will only work if the methods are indeed getting or setting a simple
# type. If this is not the case, or you want to show the methods anyway, you
-# should set this option to NO.
+# should set this options to NO.
# The default value is: YES.
IDL_PROPERTY_SUPPORT = YES
@@ -362,8 +362,8 @@ IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
-# If one adds a struct or class to a group and this option is enabled, then also
-# any nested class or struct is added to the same group. By default this option
+# If one adds a struct or class to a group and this options is enabled, then also
+# any nested class or struct is added to the same group. By default this options
# is disabled and one has to add nested compounds explicitly via \ingroup.
# The default value is: NO.
@@ -483,14 +483,14 @@ EXTRACT_ANON_NSPACES = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
# undocumented members inside documented classes or files. If set to NO these
# members will be included in the various overviews, but no documentation
-# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# section is generated. This options has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy. If set
-# to NO, these classes will be included in the various overviews. This option
+# to NO, these classes will be included in the various overviews. This options
# has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.
@@ -521,7 +521,7 @@ INTERNAL_DOCS = NO
# names in lower-case letters. If set to YES, upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
+# and Mac users are advised to set this options to NO.
# The default value is: system dependent.
CASE_SENSE_NAMES = NO
@@ -584,9 +584,9 @@ SORT_BRIEF_DOCS = NO
# (brief and detailed) documentation of class members so that constructors and
# destructors are listed first. If set to NO the constructors will appear in the
# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
-# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# Note: If SORT_BRIEF_DOCS is set to NO this options is ignored for sorting brief
# member documentation.
-# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# Note: If SORT_MEMBER_DOCS is set to NO this options is ignored for sorting
# detailed member documentation.
# The default value is: NO.
@@ -602,14 +602,14 @@ SORT_GROUP_NAMES = NO
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
# fully-qualified names, including namespaces. If set to NO, the class list will
# be sorted only by class name, not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the alphabetical
+# Note: This options is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This options applies only to the class list, not to the alphabetical
# list.
# The default value is: NO.
SORT_BY_SCOPE_NAME = NO
-# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# If the STRICT_PROTO_MATCHING options is enabled and doxygen fails to do proper
# type resolution of all parameters of a function it will reject a match between
# the prototype and the implementation of a member function even if there is
# only one candidate or it is obvious which candidate to choose by doing a
@@ -695,8 +695,8 @@ FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
# by doxygen. The layout file controls the global structure of the generated
# output files in an output format independent way. To create the layout file
-# that represents doxygen's defaults, run doxygen with the -l option. You can
-# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# that represents doxygen's defaults, run doxygen with the -l options. You can
+# optionally specify a file name after the options, if omitted DoxygenLayout.xml
# will be used as the name of the layout file.
#
# Note that if you run doxygen from a directory containing a file called
@@ -750,7 +750,7 @@ WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
-# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# This WARN_NO_PARAMDOC options can be enabled to get warnings for functions that
# are documented, but have no documentation for their parameters or return
# value. If set to NO, doxygen will only warn about wrong or incomplete
# parameter documentation, but not about the absence of documentation.
@@ -1036,8 +1036,8 @@ VERBATIM_HEADERS = YES
# cost of reduced performance. This can be particularly helpful with template
# rich C++ code for which doxygen's built-in parser lacks the necessary type
# information.
-# Note: The availability of this option depends on whether or not doxygen was
-# generated with the -Duse-libclang=ON option for CMake.
+# Note: The availability of this options depends on whether or not doxygen was
+# generated with the -Duse-libclang=ON options for CMake.
# The default value is: NO.
CLANG_ASSISTED_PARSING = NO
@@ -1144,7 +1144,7 @@ HTML_STYLESHEET =
# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
# cascading style sheets that are included after the standard style sheets
-# created by doxygen. Using this option one can overrule certain style aspects.
+# created by doxygen. Using this options one can overrule certain style aspects.
# This is preferred over using HTML_STYLESHEET since it does not replace the
# standard style sheet and is therefore more robust against future updates.
# Doxygen will copy the style sheet files to the output directory.
@@ -1418,7 +1418,7 @@ ECLIPSE_DOC_ID = org.doxygen.Project
# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
# of each HTML page. A value of NO enables the index and the value YES disables
# it. Since the tabs in the index contain the same information as the navigation
-# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# tree, you can set this options to YES if you also set GENERATE_TREEVIEW to YES.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1435,7 +1435,7 @@ DISABLE_INDEX = NO
# sheet generated by doxygen has an example that shows how to put an image at
# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
# the same information as the tab index, you could consider setting
-# DISABLE_INDEX to YES when enabling this option.
+# DISABLE_INDEX to YES when enabling this options.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1458,7 +1458,7 @@ ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
-# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# If the EXT_LINKS_IN_WINDOW options is set to YES, doxygen will open links to
# external symbols imported via tag files in a separate window.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1478,19 +1478,19 @@ FORMULA_FONTSIZE = 10
# generated for formulas are transparent PNGs. Transparent PNGs are not
# supported properly for IE 6.0, but are supported on all modern browsers.
#
-# Note that when changing this option you need to delete any form_*.png files in
+# Note that when changing this options you need to delete any form_*.png files in
# the HTML output directory before the changes have effect.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
FORMULA_TRANSPARENT = YES
-# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# Enable the USE_MATHJAX options to render LaTeX formulas using MathJax (see
# http://www.mathjax.org) which uses client side Javascript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
-# to it using the MATHJAX_RELPATH option.
+# to it using the MATHJAX_RELPATH options.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1507,7 +1507,7 @@ USE_MATHJAX = NO
MATHJAX_FORMAT = HTML-CSS
# When MathJax is enabled you need to specify the location relative to the HTML
-# output directory using the MATHJAX_RELPATH option. The destination directory
+# output directory using the MATHJAX_RELPATH options. The destination directory
# should contain the MathJax.js script. For instance, if the mathjax directory
# is located at the same level as the HTML output directory, then
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
@@ -1543,13 +1543,13 @@ MATHJAX_CODEFILE =
# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
# search using the keyboard; to jump to the search box use <access key> + S
# (what the <access key> is depends on the OS and browser, but it is typically
-# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# <CTRL>, <ALT>/<options>, or both). Inside the search box use the <cursor down
# key> to jump into the search results window, the results can be navigated
# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
# the search. The filter options can be selected when the cursor is inside the
# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
# to select a filter and <Enter> or <escape> to activate or cancel the filter
-# option.
+# options.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1570,7 +1570,7 @@ SERVER_BASED_SEARCH = NO
# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
# script for searching. Instead the search results are written to an XML file
# which needs to be processed by an external indexer. Doxygen will invoke an
-# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# external search engine pointed to by the SEARCHENGINE_URL options to obtain the
# search results.
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
@@ -1640,7 +1640,7 @@ LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked.
#
-# Note that when enabling USE_PDFLATEX this option is only used for generating
+# Note that when enabling USE_PDFLATEX this options is only used for generating
# bitmaps for formulas in the HTML output, but not in the Makefile that is
# written to the output directory.
# The default file is: latex.
@@ -1677,7 +1677,7 @@ PAPER_TYPE = a4
# by its name or with the correct syntax as to be used with the LaTeX
# \usepackage command. To get the times font for instance you can specify :
# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
-# To use the option intlimits with the amsmath package you can specify:
+# To use the options intlimits with the amsmath package you can specify:
# EXTRA_PACKAGES=[intlimits]{amsmath}
# If left blank no extra packages will be included.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1713,7 +1713,7 @@ LATEX_FOOTER =
# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
# LaTeX style sheets that are included after the standard style sheets created
-# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# by doxygen. Using this options one can overrule certain style aspects. Doxygen
# will copy the style sheet files to the output directory.
# Note: The order of the extra style sheet files is of importance (e.g. the last
# style sheet in the list overrules the setting of the previous ones in the
@@ -1740,7 +1740,7 @@ LATEX_EXTRA_FILES =
PDF_HYPERLINKS = YES
# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
-# the PDF file directly from the LaTeX files. Set this option to YES, to get a
+# the PDF file directly from the LaTeX files. Set this options to YES, to get a
# higher quality PDF documentation.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1749,7 +1749,7 @@ USE_PDFLATEX = YES
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
# command to the generated LaTeX files. This will instruct LaTeX to keep running
-# if errors occur, instead of asking the user for help. This option is also used
+# if errors occur, instead of asking the user for help. This options is also used
# when generating formulas in HTML.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -2053,7 +2053,7 @@ INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that are
-# defined before the preprocessor is started (similar to the -D option of e.g.
+# defined before the preprocessor is started (similar to the -D options of e.g.
# gcc). The argument of the tag is a list of macros of the form: name or
# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
# is assumed. To prevent a macro definition from being undefined via #undef or
@@ -2139,7 +2139,7 @@ PERL_PATH = /usr/bin/perl
# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
-# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# NO turns the diagrams off. Note that this options also works with HAVE_DOT
# disabled, but it is recommended to install and use dot, since it yields more
# powerful graphs.
# The default value is: YES.
@@ -2171,7 +2171,7 @@ HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz (see:
# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
-# Bell Labs. The other options in this section have no effect if this option is
+# Bell Labs. The other options in this section have no effect if this options is
# set to NO
# The default value is: NO.
@@ -2285,7 +2285,7 @@ INCLUDED_BY_GRAPH = YES
# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
# dependency graph for every global function or class method.
#
-# Note that enabling this option will significantly increase the time of a run.
+# Note that enabling this options will significantly increase the time of a run.
# So in most cases it will be better to enable call graphs for selected
# functions only using the \callgraph command. Disabling a call graph can be
# accomplished by means of the command \hidecallgraph.
@@ -2297,7 +2297,7 @@ CALL_GRAPH = NO
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
# dependency graph for every global function or class method.
#
-# Note that enabling this option will significantly increase the time of a run.
+# Note that enabling this options will significantly increase the time of a run.
# So in most cases it will be better to enable caller graphs for selected
# functions only using the \callergraph command. Disabling a caller graph can be
# accomplished by means of the command \hidecallergraph.
@@ -2337,7 +2337,7 @@ DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
-# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# If DOT_IMAGE_FORMAT is set to svg, then this options can be set to YES to
# enable generation of interactive SVG images that allow zooming and panning.
#
# Note that this requires a modern browser other than Internet Explorer. Tested
@@ -2407,7 +2407,7 @@ DOT_GRAPH_MAX_NODES = 50
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
# generated by dot. A depth value of 3 means that only nodes reachable from the
# root by following a path via at most 3 edges will be shown. Nodes that lay
-# further from the root node will be omitted. Note that setting this option to 1
+# further from the root node will be omitted. Note that setting this options to 1
# or 2 may greatly reduce the computation time needed for large code bases. Also
# note that the size of a graph can be further restricted by
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
@@ -2420,7 +2420,7 @@ MAX_DOT_GRAPH_DEPTH = 0
# background. This is disabled by default, because dot on Windows does not seem
# to support this out of the box.
#
-# Warning: Depending on the platform used, enabling this option may lead to
+# Warning: Depending on the platform used, enabling this options may lead to
# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
# read).
# The default value is: NO.
diff --git a/README.md b/README.md
index 79d825c..6984dd0 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
## State
- [x] Bot API 3.0 ~ 3.6
-- [x] Bot API 4.0 (Implemented all APIs except 'Telegram Passport')
+- [x] Bot API 4.0 ~ 4.4 (Implemented all APIs except 'Telegram Passport')
## Sample
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index ec9edf8..02e68a5 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -290,6 +290,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
+
Message::Ptr sendVideo(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> video, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const boost::variant<InputFile::Ptr, std::string> thumb = "", const std::string& caption = "",
int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
@@ -584,7 +585,7 @@ public:
/**
* @brief Use this method to delete messages sent by bot (or by other users if bot is admin).
- * @param chatId Unique identifier for the target chat.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
* @param messageId Unique identifier for the target message.
*/
void deleteMessage(int64_t chatId, int32_t messageId) const;
@@ -677,8 +678,7 @@ public:
* @param canAddWebPagePreviews Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages.
* @return True on success
*/
- bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0, bool canSendMessages = false,
- bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canAddWebPagePreviews = false) const;
+ bool restrictChatMember(int64_t chatId, int32_t userId, ChatPermissions::Ptr permissions, uint64_t untilDate = 0) const;
/**
* @brief Use this method to promote or demote a user in a supergroup or a channel.
@@ -698,6 +698,14 @@ public:
bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const;
/**
+ * @brief Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success.
+ * @param chatId Unique identifier for the target chat of the target supergroup.
+ * @param permissions New default chat permissions.
+ * @return True on success
+ */
+ bool setChatPermissions(int64_t chatId, ChatPermissions::Ptr permissions) const;
+
+ /**
* @brief Use this method to generate a new invite link for a chat; any previously generated link is revoked.
* @param chatId Unique identifier for the target chat.
* @return The new invite link as String on success.
@@ -745,8 +753,8 @@ public:
bool setChatDescription(int64_t chatId, const std::string& description) const;
/**
- * @brief Use this method to pin a message in a supergroup or a channel.
- * @param chatId Unique identifier for the target chat.
+ * @brief Use this method to pin a message in a group, a supergroup, or a channel.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
* @param messageId Identifier of a message to pin.
* @param disableNotification Optional. Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels.
* @return True on success
@@ -754,8 +762,8 @@ public:
bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification = false) const;
/**
- * @brief Use this method to unpin a message in a supergroup or a channel.
- * @param chatId Unique identifier for the target chat.
+ * @brief Use this method to unpin a message in a group, a supergroup, or a channel.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
* @return True on success
*/
bool unpinChatMessage(int64_t chatId) const;
@@ -791,7 +799,6 @@ public:
std::vector<GameHighScore::Ptr> getGameHighScores(int32_t userId, int32_t score, bool force = false,
bool disableEditMessage = false, int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const;
-
/**
* @brief Downloads file from Telegram and saves it in memory.
* @param filePath Telegram file path.
@@ -800,6 +807,33 @@ public:
*/
std::string downloadFile(const std::string& filePath, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
+ /**
+ * @brief Use this method to send a poll.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
+ * @param question Poll question, 1-255 characters.
+ * @param options List of answer options, 2-10 strings 1-100 characters each.
+ * @param disable_notification Optional. Sends the message silenty.
+ * @param reply_to_message_id Optional. If the message is a reply, ID of the original message.
+ * @param reply_markup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
+ *
+ * @return On success, the sent message is returned.
+ */
+ Message::Ptr sendPoll(int64_t chatId, std::string question, std::vector<std::string> options, bool disable_notification=false, int32_t reply_to_message_id=0,GenericReply::Ptr reply_markup = std::make_shared<GenericReply>()) const;
+
+ /**
+ * @brief Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned..
+ * @param chatId Unique identifier for the target chat or username of the target channel.
+ * @param question Poll question, 1-255 characters.
+ * @param options List of answer options, 2-10 strings 1-100 characters each.
+ * @param disable_notification Optional. Sends the message silenty.
+ * @param reply_to_message_id Optional. If the message is a reply, ID of the original message.
+ * @param reply_markup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
+ *
+ * @return On success, the sent message is returned.
+ */
+
+ Poll::Ptr stopPoll(int64_t chatId, int64_t messageId, InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const;
+
private:
boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 979ba55..6cda5a7 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -36,6 +36,9 @@
#include "tgbot/types/Document.h"
#include "tgbot/types/Sticker.h"
#include "tgbot/types/StickerSet.h"
+#include "tgbot/types/Poll.h"
+#include "tgbot/types/PollOption.h"
+#include "tgbot/types/ChatPermissions.h"
#include "tgbot/types/MaskPosition.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/Voice.h"
@@ -145,6 +148,15 @@ public:
MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const;
std::string parseMaskPosition(const MaskPosition::Ptr& object) const;
+ Poll::Ptr parseJsonAndGetPoll(const boost::property_tree::ptree& data) const;
+ std::string parsePoll(const Poll::Ptr& object) const;
+
+ PollOption::Ptr parseJsonAndGetPollOption(const boost::property_tree::ptree& data) const;
+ std::string parsePollOption(const PollOption::Ptr& object) const;
+
+ ChatPermissions::Ptr parseJsonAndGetChatPermissions(const boost::property_tree::ptree& data) const;
+ std::string parseChatPermissions(const ChatPermissions::Ptr& object) const;
+
Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const;
std::string parseVideo(const Video::Ptr& object) const;
@@ -476,6 +488,7 @@ private:
json += std::to_string(value);
json += ',';
}
+
inline void appendToJson(std::string &json, const std::string &varName, const int &value) const { appendToJsonNumber(json, varName, value); }
inline void appendToJson(std::string &json, const std::string &varName, const long &value) const { appendToJsonNumber(json, varName, value); }
inline void appendToJson(std::string &json, const std::string &varName, const long long &value) const { appendToJsonNumber(json, varName, value); }
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
index a402ebb..eb38ec7 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -27,6 +27,7 @@
#include <memory>
#include "tgbot/types/ChatPhoto.h"
+#include "tgbot/types/ChatPermissions.h"
namespace TgBot {
@@ -111,6 +112,12 @@ public:
std::shared_ptr<Message> pinnedMessage;
/**
+ * @brief Optional. Default chat member permissions, for groups and supergroups.
+ * Returned only in getChat.
+ */
+ ChatPermissions::Ptr permissions;
+
+ /**
* @brief Optional. For supergroups, name of group sticker set.
* Returned only in getChat.
*/
diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h
index facfec2..f5e5acd 100644
--- a/include/tgbot/types/ChatMember.h
+++ b/include/tgbot/types/ChatMember.h
@@ -77,6 +77,11 @@ public:
bool canPinMessages = false;
/**
+ * @brief Optional. Restricted only. True, if the user is a member of the chat at the moment of the request.
+ */
+ bool isMember = false;
+
+ /**
* @brief Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user).
*/
bool canPromoteMembers = false;
@@ -97,6 +102,11 @@ public:
bool canSendOtherMessages = false;
/**
+ * @brief Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages.
+ */
+ bool canSendPolls = false;
+
+ /**
* @brief Optional. Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages.
*/
bool canAddWebPagePreviews = false;
diff --git a/include/tgbot/types/ChatPermissions.h b/include/tgbot/types/ChatPermissions.h
new file mode 100644
index 0000000..8db32e6
--- /dev/null
+++ b/include/tgbot/types/ChatPermissions.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2019 Marcel Alexandru
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TGBOT_CPP_CHATPERMISSIONS_H
+#define TGBOT_CPP_CHATPERMISSIONS_H
+
+#include <memory>
+#include <string>
+
+
+namespace TgBot {
+
+ /**
+ * @brief This object describes actions that a non-administrator user is allowed to take in a chat.
+ * @ingroup types
+ */
+
+ class ChatPermissions {
+ public:
+ typedef std::shared_ptr<ChatPermissions> Ptr;
+
+ /**
+ * @brief Optional. True, if the user is allowed to send text messages, contacts, locations and venues.
+ */
+ bool canSendMessages = false;
+
+ /**
+ * @brief Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages.
+ */
+ bool canSendMediaMessages = false;
+
+ /**
+ * @brief Optional. True, if the user is allowed to send polls, implies can_send_messages.
+ */
+ bool canSendPolls = false;
+
+ /**
+ * @brief Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages.
+ */
+ bool canSendOtherMessages = false;
+
+ /**
+ * @brief Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages.
+ */
+ bool canAddWebPagePreviews = false;
+
+ /**
+ * @brief Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups.
+ */
+ bool canChangeInfo = false;
+
+ /**
+ * @brief Optional. True, if the user is allowed to invite new users to the chat.
+ */
+ bool canInviteUsers = false;
+
+ /**
+ * @brief Optional. True, if the user is allowed to pin messages. Ignored in public supergroups.
+ */
+ bool canPinMessages = false;
+
+
+
+ };
+}
+
+#endif //TGBOT_CPP_CHATPERMISSIONS_H
diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h
index 4b83087..f274825 100644
--- a/include/tgbot/types/InlineKeyboardButton.h
+++ b/include/tgbot/types/InlineKeyboardButton.h
@@ -9,6 +9,7 @@
#include <memory>
#include "tgbot/types/CallbackGame.h"
+#include "tgbot/types/LoginUrl.h"
namespace TgBot {
@@ -32,6 +33,11 @@ public:
std::string url;
/**
+ * @brief Optional. An HTTP URL used to automatically authorize the user.
+ */
+ LoginUrl::Ptr loginUrl;
+
+ /**
* @brief Optional. Data to be sent in a callback query to the bot when button is pressed.
*/
std::string callbackData;
diff --git a/include/tgbot/types/LoginUrl.h b/include/tgbot/types/LoginUrl.h
new file mode 100644
index 0000000..1627399
--- /dev/null
+++ b/include/tgbot/types/LoginUrl.h
@@ -0,0 +1,45 @@
+//
+// Created by alexandrumarcel on 19.11.2019.
+//
+
+#ifndef TGBOT_CPP_LOGINURL_H
+#define TGBOT_CPP_LOGINURL_H
+
+#include <memory>
+#include <string>
+#include <vector>
+
+
+namespace TgBot{
+ /**
+ * @brief This object represents a Poll.
+ *
+ * @ingroup types
+ */
+ class LoginUrl{
+ public:
+ typedef std::shared_ptr<LoginUrl> Ptr;
+
+ /**
+ * @brief UAn HTTP URL to be opened with user authorization data added to the query string when the button is pressed..
+ */
+ std::string url;
+
+ /**
+ * @brief Optional. New text of the button in forwarded messages.
+ */
+ std::string forward_text;
+
+ /**
+ * @brief Optional. Username of a bot, which will be used for user authorization.
+ */
+ std::string bot_username;
+
+ /**
+ * @brief Optional. Pass True to request the permission for your bot to send messages to the user.
+ */
+ bool request_write_access;
+ };
+}
+
+#endif //TGBOT_CPP_LOGINURL_H
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index f92eeaf..9e831bc 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -34,6 +34,7 @@
#include "tgbot/types/Document.h"
#include "tgbot/types/Animation.h"
#include "tgbot/types/Sticker.h"
+#include "tgbot/types/Poll.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/Contact.h"
#include "tgbot/types/Location.h"
@@ -44,6 +45,7 @@
#include "tgbot/types/Voice.h"
#include "tgbot/types/Invoice.h"
#include "tgbot/types/SuccessfulPayment.h"
+#include "tgbot/types/InlineKeyboardMarkup.h"
namespace TgBot {
@@ -97,6 +99,11 @@ public:
std::string forwardSignature;
/**
+ * @brief Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
+ */
+ std::string forwardSenderName;
+
+ /**
* @brief Optional. For forwarded messages, date the original message was sent in Unix time.
*/
int32_t forwardDate;
@@ -194,6 +201,11 @@ public:
Venue::Ptr venue;
/**
+ * @brief Optional. Message is a poll, information about the poll.
+ */
+ Poll::Ptr poll;
+
+ /**
* @brief Optional. A new member was added to the group, information about them (this member may be bot itself).
*/
User::Ptr newChatMember;
@@ -267,6 +279,11 @@ public:
* @brief Optional. The domain name of the website on which the user has logged in.
*/
std::string connectedWebsite;
+
+ /**
+ * @brief Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.
+ */
+ InlineKeyboardMarkup::Ptr replyMarkup;
};
}
diff --git a/include/tgbot/types/Poll.h b/include/tgbot/types/Poll.h
new file mode 100644
index 0000000..e218997
--- /dev/null
+++ b/include/tgbot/types/Poll.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2019 Nitan Alexandru Marcel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TGBOT_POLL_H
+#define TGBOT_POLL_H
+
+#include <memory>
+#include <string>
+#include <vector>
+#include "tgbot/types/PollOption.h"
+
+namespace TgBot {
+ /**
+ * @brief This object represents a Poll.
+ *
+ * @ingroup types
+ */
+ class Poll {
+ public:
+ typedef std::shared_ptr<Poll> Ptr;
+
+ /**
+ * @brief Unique poll identifier.
+ */
+ int64_t id;
+
+ /**
+ * @brief Poll question, 1-255 characters.
+ */
+ std::string question;
+
+ /**
+ * @brief List of poll options.
+ */
+ PollOption::Ptr options;
+
+ /**
+ * @brief True, if the poll is closed.
+ */
+ bool is_closed;
+ };
+}
+
+#endif //TGBOT_POLL_H
diff --git a/include/tgbot/types/PollOption.h b/include/tgbot/types/PollOption.h
new file mode 100644
index 0000000..0d87870
--- /dev/null
+++ b/include/tgbot/types/PollOption.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2019 Nitan Alexandru Marcel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#ifndef TGBOT_POLLOPTION_H
+#define TGBOT_POLLOPTION_H
+
+namespace TgBot {
+
+class PollOption {
+
+public:
+ typedef std::shared_ptr<PollOption> Ptr;
+
+ /**
+ * @brief Option text, 1-100 characters.
+ */
+ std::string text;
+
+ /**
+ * @brief Number of users that voted for this option.
+ */
+ int64_t voter_count;
+};
+
+}
+
+#endif //TGBOT_POLLOPTION_H
diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h
index 9fd200a..68fc574 100644
--- a/include/tgbot/types/Sticker.h
+++ b/include/tgbot/types/Sticker.h
@@ -57,6 +57,11 @@ public:
int32_t height;
/**
+ * @brief True, if the sticker is animated.
+ */
+ bool isAnimated = false;
+
+ /**
* @brief Optional. Optional. Sticker thumbnail in .webp or .jpg format.
*/
PhotoSize::Ptr thumb;
diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h
index d08fd4a..deddf74 100644
--- a/include/tgbot/types/StickerSet.h
+++ b/include/tgbot/types/StickerSet.h
@@ -52,6 +52,11 @@ public:
std::string title;
/**
+ * @brief True, if the sticker set contains animated stickers.
+ */
+ bool isAnimated = false;
+
+ /**
* @brief True, if the sticker set contains masks.
*/
bool containsMasks = false;
diff --git a/src/Api.cpp b/src/Api.cpp
index 9996108..19681f7 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -276,6 +276,7 @@ bool Api::answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok,
return sendRequest("answerPreCheckoutQuery", args).get<bool>("", false);
}
+
Message::Ptr Api::sendSticker(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> sticker, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.reserve(5);
@@ -981,28 +982,17 @@ bool Api::unbanChatMember(int64_t chatId, int32_t userId) const {
args.emplace_back("user_id", userId);
return sendRequest("unbanChatMember", args).get<bool>("", false);
}
-
-bool Api::restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate, bool canSendMessages,
- bool canSendMediaMessages, bool canSendOtherMessages, bool canAddWebPagePreviews) const {
+bool Api::restrictChatMember(int64_t chatId, int32_t userId, TgBot::ChatPermissions::Ptr permissions,
+ uint64_t untilDate) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(4);
args.emplace_back("chat_id", chatId);
args.emplace_back("user_id", userId);
+ args.emplace_back("permissions", _tgTypeParser.parseChatPermissions(permissions));
if (untilDate) {
args.emplace_back("until_date", untilDate);
}
- if (canSendMessages) {
- args.emplace_back("can_send_messages", canSendMessages);
- }
- if (canSendMediaMessages) {
- args.emplace_back("can_send_media_messages", canSendMediaMessages);
- }
- if (canSendOtherMessages) {
- args.emplace_back("can_send_other_messages", canSendOtherMessages);
- }
- if (canAddWebPagePreviews) {
- args.emplace_back("can_add_web_page_previews", canAddWebPagePreviews);
- }
+
return sendRequest("restrictChatMember", args).get<bool>("", false);
}
@@ -1036,6 +1026,14 @@ bool Api::promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo,
return sendRequest("promoteChatMember", args).get<bool>("", false);
}
+bool Api::setChatPermissions(int64_t chatId, ChatPermissions::Ptr permissions) const{
+ vector<HttpReqArg> args;
+ args.reserve(2);
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("permissions", _tgTypeParser.parseChatPermissions(permissions));
+ return sendRequest("setChatPermissions", args).get<bool>("", false);
+}
+
string Api::exportChatInviteLink(int64_t chatId) const {
vector<HttpReqArg> args;
args.reserve(1);
@@ -1142,6 +1140,43 @@ void Api::deleteMessage(int64_t chatId, int32_t messageId) const {
sendRequest("deleteMessage", { HttpReqArg("chat_id", chatId), HttpReqArg("message_id", messageId) });
}
+Message::Ptr Api::sendPoll(int64_t chat_id, std::string question, std::vector<std::string> options, bool disable_notification, int32_t reply_to_message_id,GenericReply::Ptr reply_markup) const {
+ vector<HttpReqArg> args;
+ args.reserve(6);
+ args.emplace_back("chat_id", chat_id);
+ args.emplace_back("question", question);
+ std::string json_array;
+ json_array = "[";
+ for(const auto &arr : options){
+ json_array += "\"" + arr + "\"" + ",";
+ }
+ json_array.pop_back();
+ json_array += "]";
+ args.emplace_back("options", json_array);
+
+ if (disable_notification){
+ args.emplace_back("disable_notification", disable_notification);
+ }
+ if (reply_to_message_id!=0){
+ args.emplace_back("reply_to_message_id", reply_to_message_id);
+ }
+ if (reply_markup){
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(reply_markup));
+ }
+ return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args));
+}
+
+Poll::Ptr Api::stopPoll(int64_t chatId, int64_t messageId, const InlineKeyboardMarkup::Ptr replyMarkup) const {
+ vector<HttpReqArg> args;
+ args.reserve(3);
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("message_id", messageId);
+ if (replyMarkup){
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ }
+ return _tgTypeParser.parseJsonAndGetPoll(sendRequest("stopPoll", args));
+}
+
ptree Api::sendRequest(const string& method, const vector<HttpReqArg>& args) const {
string url = "https://api.telegram.org/bot";
url += _token;
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index daa7b4b..999dbc1 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -144,6 +144,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->forwardFromChat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "forward_from_chat");
result->forwardFromMessageId = data.get<int32_t>("forward_from_message_id", 0);
result->forwardSignature = data.get("forward_signature", "");
+ result->forwardSenderName = data.get("forward_sender_name", "");
result->forwardDate = data.get("forward_date", 0);
result->replyToMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "reply_to_message");
result->editDate = data.get<int32_t>("edit_date", 0);
@@ -161,6 +162,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->voice = tryParseJson<Voice>(&TgTypeParser::parseJsonAndGetVoice, data, "voice");
result->contact = tryParseJson<Contact>(&TgTypeParser::parseJsonAndGetContact, data, "contact");
result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
+ result->poll = tryParseJson<Poll>(&TgTypeParser::parseJsonAndGetPoll, data, "poll");
result->newChatMember = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "new_chat_participant");
result->newChatMembers = parseJsonAndGetArray<User>(&TgTypeParser::parseJsonAndGetUser, data, "new_chat_members");
result->leftChatMember = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "left_chat_participant");
@@ -177,6 +179,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->invoice = tryParseJson<Invoice>(&TgTypeParser::parseJsonAndGetInvoice, data, "invoice");
result->successfulPayment = tryParseJson<SuccessfulPayment>(&TgTypeParser::parseJsonAndGetSuccessfulPayment, data, "successful_payment");
result->connectedWebsite = data.get("connected_website", "");
+ result->replyMarkup = tryParseJson<InlineKeyboardMarkup>(&TgTypeParser::parseJsonAndGetInlineKeyboardMarkup, data, "reply_markup");
return result;
}
@@ -194,6 +197,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "forward_from_chat", parseChat(object->forwardFromChat));
appendToJson(result, "forward_from_message_id", object->forwardFromMessageId);
appendToJson(result, "forward_signature", object->forwardSignature);
+ appendToJson(result, "forward_sender_name", object->forwardSenderName);
appendToJson(result, "forward_date", object->forwardDate);
appendToJson(result, "reply_to_message", parseMessage(object->replyToMessage));
appendToJson(result, "edit_date", object->editDate);
@@ -208,6 +212,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "voice", parseVoice(object->voice));
appendToJson(result, "contact", parseContact(object->contact));
appendToJson(result, "location", parseLocation(object->location));
+ appendToJson(result, "poll", parsePoll(object->poll));
appendToJson(result, "new_chat_member", parseUser(object->newChatMember));
appendToJson(result, "new_chat_members", parseArray(&TgTypeParser::parseUser, object->newChatMembers));
appendToJson(result, "left_chat_member", parseUser(object->leftChatMember));
@@ -224,6 +229,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "connected_website", object->connectedWebsite);
appendToJson(result, "invoice", parseInvoice(object->invoice));
appendToJson(result, "successful_payment", parseSuccessfulPayment(object->successfulPayment));
+ appendToJson(result, "reply_markup", parseInlineKeyboardMarkup(object->replyMarkup));
removeLastComma(result);
result += '}';
return result;
@@ -312,6 +318,7 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const ptree& data) const {
result->fileId = data.get<string>("file_id");
result->width = data.get<int32_t>("width");
result->height = data.get<int32_t>("height");
+ result->isAnimated = data.get<bool>("is_animated", false);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->emoji = data.get("emoji", "");
result->setName = data.get("set_name", "");
@@ -329,6 +336,7 @@ string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "width", object->width);
appendToJson(result, "height", object->height);
+ appendToJson(result, "is_animated", object->isAnimated);
appendToJson(result, "thumb", parsePhotoSize(object->thumb));
appendToJson(result, "emoji", object->emoji);
appendToJson(result, "file_size", object->fileSize);
@@ -342,6 +350,7 @@ StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const ptree& data) const
result->name = data.get("name", "");
result->title = data.get("title", "");
result->containsMasks = data.get<bool>("contains_masks", false);
+ result->isAnimated = data.get<bool>("is_animated", false);
result->stickers = parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "stickers");
return result;
}
@@ -354,6 +363,7 @@ string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const {
result += '{';
appendToJson(result, "name", object->name);
appendToJson(result, "title", object->title);
+ appendToJson(result, "is_animated", object->isAnimated);
appendToJson(result, "contains_masks", object->containsMasks);
appendToJson(result, "stickers", parseArray(&TgTypeParser::parseSticker, object->stickers));
removeLastComma(result);
@@ -385,6 +395,82 @@ string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) const {
return result;
}
+Poll::Ptr TgTypeParser::parseJsonAndGetPoll(const ptree& data) const {
+ auto result(make_shared<Poll>());
+ result->id = data.get("id", 0);
+ result->question = data.get("question", "");
+ result->options = tryParseJson<PollOption>(&TgTypeParser::parseJsonAndGetPollOption, data, "options");
+ result->is_closed = data.get<bool>("is_closed");
+ return result;
+}
+
+string TgTypeParser::parsePoll(const Poll::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "id", object->id);
+ appendToJson(result, "question", object->question);
+ appendToJson(result, "options", parsePollOption(object->options));
+ appendToJson(result, "is_closed", object->is_closed);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+PollOption::Ptr TgTypeParser::parseJsonAndGetPollOption(const ptree& data) const {
+ auto result(make_shared<PollOption>());
+ result->text = data.get("text", "");
+ result->voter_count = data.get("voter_count", 0);
+ return result;
+}
+
+string TgTypeParser::parsePollOption(const PollOption::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "text", object->text);
+ appendToJson(result, "voter_count", object->voter_count);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+ChatPermissions::Ptr TgTypeParser::parseJsonAndGetChatPermissions(const ptree& data) const {
+ auto result(make_shared<ChatPermissions>());
+ result->canSendMessages = data.get<bool>("can_send_messages");
+ result->canSendMediaMessages = data.get<bool>("can_send_media_messages");
+ result->canSendPolls = data.get<bool>("can_send_polls");
+ result->canSendOtherMessages = data.get<bool>("can_send_other_messages");
+ result->canAddWebPagePreviews = data.get<bool>("can_add_web_page_previews");
+ result->canChangeInfo = data.get<bool>("can_change_info");
+ result->canInviteUsers = data.get<bool>("can_invite_users");
+ result->canPinMessages = data.get<bool>("can_pin_messages");
+ return result;
+}
+
+string TgTypeParser::parseChatPermissions(const ChatPermissions::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "can_send_messages", object->canSendMessages);
+ appendToJson(result, "can_send_media_messages", object->canSendMediaMessages);
+ appendToJson(result, "can_send_polls", object->canSendPolls);
+ appendToJson(result, "can_send_other_messages", object->canSendOtherMessages);
+ appendToJson(result, "can_add_web_page_previews", object->canAddWebPagePreviews);
+ appendToJson(result, "can_change_info", object->canChangeInfo);
+ appendToJson(result, "can_invite_users", object->canInviteUsers);
+ appendToJson(result, "can_pin_messages", object->canPinMessages);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
Video::Ptr TgTypeParser::parseJsonAndGetVideo(const ptree& data) const {
auto result(make_shared<Video>());
result->fileId = data.get<string>("file_id");
@@ -877,6 +963,7 @@ ChatMember::Ptr TgTypeParser::parseJsonAndGetChatMember(const boost::property_tr
result->canInviteUsers = data.get<bool>("can_invite_users", false);
result->canRestrictMembers = data.get<bool>("can_restrict_members", false);
result->canPinMessages = data.get<bool>("can_pin_messages", false);
+ result->isMember = data.get<bool>("is_member", false);
result->canPromoteMembers = data.get<bool>("can_promote_messages", false);
result->canSendMessages = data.get<bool>("can_send_messages", false);
result->canSendMediaMessages = data.get<bool>("can_send_media_messages", false);
@@ -1710,6 +1797,7 @@ InlineKeyboardButton::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardButton(cons
auto result(make_shared<InlineKeyboardButton>());
result->text = data.get<string>("text");
result->url = data.get<string>("url", "");
+ result->loginUrl = make_shared<LoginUrl>();
result->callbackData = data.get<string>("callback_data", "");
result->switchInlineQuery = data.get<string>("switch_inline_query", "");
result->switchInlineQueryCurrentChat = data.get<string>("switch_inline_query_current_chat", "");
@@ -2128,5 +2216,4 @@ void TgTypeParser::appendToJson(string& json, const string& varName, const strin
}
json += ',';
}
-
}