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

Abstract class for bot commands. More...

#include <command.hpp>

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

Public Member Functions

virtual void callClosure (T &, const types::Update &)=0
 Forward the update to another function. More...
 
virtual bool isValid (const types::Update &)=0
 Does the update trigger this command? More...
 

Public Attributes

const EUpdate type
 type of the update for which the command will be triggered.
 

Protected Member Functions

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::Command< T >

Abstract class for bot commands.

Command that will be triggered when some conditions are met in the current update. Inherit this class to implements behavior and condition that have to be met before triggering the command.

Member Function Documentation

◆ callClosure()

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

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.

Implemented in MessageCommand< T >.

◆ isValid()

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

Does the update trigger this command?

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

Implemented in MessageCommand< T >.

◆ setCallbackQueryId()

void setCallbackQueryId ( std::string &  callback_query_id,
T &  bot 
)
inlineprotected

Set the callback query id the current update.

Parameters
callback_query_idId of the callback query received.
botBot that is processing the update.

◆ setInlineQueryId()

void setInlineQueryId ( std::string &  inline_query_id,
T &  bot 
)
inlineprotected

Set the inline query id of the bot for using AnswerInlineQuery.

Parameters
inline_query_idThe id of the inline query received.
botBot that is processing the update.

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