150 lines
5.9 KiB
MQL5
150 lines
5.9 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Messages.mqh |
|
|
//| Copyright 2026,Niquel Mendoza. |
|
|
//| https://www.mql5.com/en/users/nique_372 |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2026,Niquel Mendoza."
|
|
#property link "https://www.mql5.com/en/users/nique_372"
|
|
#property strict
|
|
|
|
|
|
#ifndef WORKFLOWSBYLEO_STEPS_MESSAGES_MQH
|
|
#define WORKFLOWSBYLEO_STEPS_MESSAGES_MQH
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Include |
|
|
//+------------------------------------------------------------------+
|
|
#include <TSN\\Telegram\\Telegram.mqh>
|
|
#include "..\\Final\\Orquestador.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
//--- Registramos las enums
|
|
MQLARTICLES_ENUMREG_REG(TELEGRAM_PARSE_MODE_HTML)
|
|
MQLARTICLES_ENUMREG_REG(TELEGRAM_PARSE_MODE_MD)
|
|
MQLARTICLES_ENUMREG_REG(TELEGRAM_PARSE_MODE_MD_2)
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Telegram |
|
|
//+------------------------------------------------------------------+
|
|
class CWorkStepGenericMessage : public CWorkflowStep
|
|
{
|
|
private:
|
|
CTlgBotMessageSender m_bot_sender;
|
|
bool m_silencioso;
|
|
ENUM_TELEGRAM_PARSE_MODE m_parse_mode;
|
|
string m_message;
|
|
|
|
public:
|
|
CWorkStepGenericMessage(void) : CWorkflowStep("SendToTlgMessage", "Message", false, 0) {}
|
|
~CWorkStepGenericMessage(void) {}
|
|
|
|
//---
|
|
bool Init(const CYmlNode& parameters) override final;
|
|
int Run() override final;
|
|
};
|
|
//---
|
|
WORKFLOWS_FACTORY_DEFINE_CREATOR(CWorkStepGenericMessage, MessageToTlg, "SendToTlgMessage", "Message")
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CWorkStepGenericMessage::Init(const CYmlNode ¶meters)
|
|
{
|
|
if(m_bot_sender.Token(m_wf.TranslateStr(parameters["token"], "")) != 0)
|
|
{
|
|
LogError("Invalid tlg bot token", FUNCION_ACTUAL);
|
|
return false;
|
|
}
|
|
m_bot_sender.ChatId(m_wf.TranslateNumber<long>(parameters["chat_id"], ""));
|
|
m_message = m_wf.TranslateStr(parameters["message"], "");
|
|
m_silencioso = m_wf.TranslateBool(parameters["silenty"], "false");
|
|
m_parse_mode = m_wf.TranslateEnum<ENUM_TELEGRAM_PARSE_MODE>(parameters["parse_mode"], "WRONG_VALUE");
|
|
return true;
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
int CWorkStepGenericMessage::Run(void)
|
|
{
|
|
return m_bot_sender.SendMessage(m_message, NULL, m_parse_mode, m_silencioso);
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Alerta |
|
|
//+------------------------------------------------------------------+
|
|
class CWorkStepGenericAlert : public CWorkflowStep
|
|
{
|
|
private:
|
|
string m_message;
|
|
|
|
public:
|
|
CWorkStepGenericAlert(void) : CWorkflowStep("Alert", "Message", false, 0) {}
|
|
~CWorkStepGenericAlert(void) {}
|
|
|
|
//---
|
|
bool Init(const CYmlNode& parameters) override final;
|
|
int Run() override final;
|
|
};
|
|
//---
|
|
WORKFLOWS_FACTORY_DEFINE_CREATOR(CWorkStepGenericAlert, MessageAlert, "Alert", "Message")
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CWorkStepGenericAlert::Init(const CYmlNode ¶meters)
|
|
{
|
|
m_message = m_wf.TranslateStr(parameters["message"], "");
|
|
return true;
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
int CWorkStepGenericAlert::Run(void)
|
|
{
|
|
Alert(m_message);
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Message to phone |
|
|
//+------------------------------------------------------------------+
|
|
class CWorkStepGenericNotification : public CWorkflowStep
|
|
{
|
|
private:
|
|
string m_message;
|
|
|
|
public:
|
|
CWorkStepGenericNotification(void) : CWorkflowStep("Notification", "Message", false, 0) {}
|
|
~CWorkStepGenericNotification(void) {}
|
|
|
|
//---
|
|
bool Init(const CYmlNode& parameters) override final;
|
|
int Run() override final;
|
|
};
|
|
//---
|
|
WORKFLOWS_FACTORY_DEFINE_CREATOR(CWorkStepGenericNotification, MessageNotification, "Notification", "Message")
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CWorkStepGenericNotification::Init(const CYmlNode ¶meters)
|
|
{
|
|
m_message = m_wf.TranslateStr(parameters["message"], "");
|
|
return true;
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
int CWorkStepGenericNotification::Run(void)
|
|
{
|
|
return SendNotification(m_message) ? 0 : 1;
|
|
}
|
|
|
|
|
|
#endif // WORKFLOWSBYLEO_STEPS_MESSAGES_MQH
|
|
//+------------------------------------------------------------------+
|