Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
Public Member Functions | List of all members
MessageCommand< T > Class Template Reference

Triggered by bot command in messages. More...

#include <message_command.hpp>

Inheritance diagram for MessageCommand< T >:
Command< T >

Public Member Functions

 MessageCommand (std::string &command, MessageClosure script)
 Construct a message command. More...
 
virtual void callClosure (T &bot, const types::Update &update)
 Forward the update to another function. More...
 
virtual bool isValid (const types::Update &update)
 Does the update trigger this command? More...
 

Additional Inherited Members

- Public Attributes inherited from Command< T >
const EUpdate type
 type of the update for which the command will be triggered.
 
- Protected Member Functions inherited from Command< T >
void setInlineQueryId (std::string &inline_query_id, T &bot)
 Set the inline query id of the bot for using AnswerInlineQuery. More...
 
void setCallbackQueryId (std::string &callback_query_id, T &bot)
 Set the callback query id the current update. More...
 

Detailed Description

template<class T>
class cppgram::commands::MessageCommand< T >

Triggered by bot command in messages.

If the message contains a bot command and it is the same as this command, call the underlying function. This command will be triggered only if the command is the first to appear in the message.

Constructor & Destructor Documentation

◆ MessageCommand()

MessageCommand ( std::string &  command,
MessageClosure  script 
)
inline

Construct a message command.

Parameters
commandString that has to appear in the bot command to trigger this object. If you want the bot to trigger on the command /start, pass "start" as command parameter.
scriptThe function that will be called if this command is triggered.

Member Function Documentation

◆ callClosure()

virtual void callClosure ( T &  ,
const types::Update &   
)
inlinevirtual

Forward the update to another function.

When the update triggers this command, the current update will be forwarded to this method. Call the underlying pointer to a function using this method. Set also bot data(chat_id, inline_query_id, callback_query_id) or some api methods will not work.

Implements Command< T >.

◆ isValid()

virtual bool isValid ( const types::Update &  )
inlinevirtual

Does the update trigger this command?

Parameters
updateCurrent update to parse.
Returns
True if the current update triggered the command.

Implements Command< T >.


The documentation for this class was generated from the following file: