Introduce MBFT::Module and MBFT::ModuleAPI
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include "modules/ModuleAPI.h"
|
||||
|
||||
MBFT::ModuleAPI::ModuleAPI(MBFT::IConnector& c)
|
||||
: connector(c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MBFT::ModuleAPI::set_context(const MBFT::InboundMessage * const ctx)
|
||||
{
|
||||
this->ctx = const_cast<MBFT::InboundMessage *>(ctx);
|
||||
}
|
||||
|
||||
void MBFT::ModuleAPI::v1_respond(const std::string& text)
|
||||
{
|
||||
if (ctx == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<MBFT::OutboundMessage> new_message = std::make_shared<MBFT::OutboundMessage>();
|
||||
MBFT::OutboundMessage& m = *new_message;
|
||||
|
||||
m.target_chat_id = ctx->chat->id;
|
||||
m.text = text;
|
||||
|
||||
connector.send(new_message);
|
||||
}
|
||||
Reference in New Issue
Block a user