2025-11-23 19:15:17 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Ea.mq5 |
|
| | | //| Copyright 2025, Niquel Mendoza. |
|
| | | //| https://www.mql5.com/es/users/nique_372/news |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2025, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com/es/users/nique_372/news"
|
| | | #property version "1.00"
|
| | | #property strict
|
| | |
|
2026-09-24 12:18:36 -05:00 | | |
|
2025-11-23 19:15:17 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Include |
|
| | | //+------------------------------------------------------------------+
|
2026-09-24 12:18:36 -05:00 | | | #include "..\\Src\\CommandsApi.mqh"
|
| | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | input string InpBotToken = "";
|
| | | input long InpBotChatId = 0;
|
2025-11-23 19:15:17 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
2026-09-24 12:18:36 -05:00 | | | //| |
|
2025-11-23 19:15:17 -05:00 | | | //+------------------------------------------------------------------+
|
2026-09-24 12:18:36 -05:00 | | | class CMyBot : public TSN::CTelegramCommandBot
|
| | | {
|
| | | protected:
|
| | | void OnCommand(int command_idx, long chat_id, TSN::CJsonNode& json) override final
|
| | | {
|
| | | switch(command_idx)
|
| | | {
|
| | | case 0: // /start
|
| | | SendMessage("Hola como estas?¿");
|
| | | break;
|
| | | case 1: // /ping
|
| | | SendMessage("Pong");
|
| | | break;
|
| | | }
|
| | | }
|
| | | };
|
2025-11-23 19:15:17 -05:00 | | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
2026-09-24 12:18:36 -05:00 | | | //| |
|
2025-11-23 19:15:17 -05:00 | | | //+------------------------------------------------------------------+
|
2026-09-24 12:18:36 -05:00 | | | CMyBot g_bot;
|
| | | TSN::CTelegramBotUpdater g_tlg_bot_poller;
|
2025-11-23 19:15:17 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Expert initialization function |
|
| | | //+------------------------------------------------------------------+
|
| | | int OnInit()
|
| | | {
|
| | | //---
|
2026-09-24 12:18:36 -05:00 | | | g_tlg_bot_poller.Token(InpBotToken);
|
| | | g_tlg_bot_poller.RegisterEvent(&g_bot, TSN::TELEGRAMBYLEO_GETUPT_K_MESSAGE);
|
| | | g_tlg_bot_poller.Init();
|
| | | g_tlg_bot_poller.AllowedUpdates();
|
| | |
|
| | | //---
|
| | | g_bot.Token(InpBotToken);
|
| | | g_bot.ChatId(InpBotChatId);
|
| | | g_bot.SetCommand("start", 0);
|
| | | g_bot.SetCommand("ping", 1);
|
| | |
|
| | |
|
2025-11-23 19:15:17 -05:00 | | | //---
|
2026-09-25 09:59:13 -05:00 | | | EventSetMillisecondTimer(1000);
|
2025-11-23 19:15:17 -05:00 | | |
|
| | | //---
|
| | | return(INIT_SUCCEEDED);
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
| | | //| Expert deinitialization function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnDeinit(const int reason)
|
| | | {
|
| | | //---
|
2026-09-24 12:18:36 -05:00 | | | g_tlg_bot_poller.UnregisterEvent(&g_bot, TSN::TELEGRAMBYLEO_GETUPT_K_MESSAGE);
|
2025-11-23 19:15:17 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|
| | | //| Expert tick function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnTick()
|
| | | {
|
| | | //---
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
2026-09-24 12:18:36 -05:00 | | | //| |
|
2025-11-23 19:15:17 -05:00 | | | //+------------------------------------------------------------------+
|
2026-09-24 12:18:36 -05:00 | | | void OnTimer(void)
|
2025-11-23 19:15:17 -05:00 | | | {
|
2026-09-24 12:18:36 -05:00 | | | g_tlg_bot_poller.GetUpdates();
|
2025-11-23 19:15:17 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|