29 lines
557 B
C++
29 lines
557 B
C++
|
|
#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);
|
||
|
|
}
|