2026-09-22 17:06:21 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Def.mqh |
|
| | | //| Copyright 2026, Niquel Mendoza. |
|
| | | //| https://www.mql5.com |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2026, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com"
|
| | | #property strict
|
| | |
|
| | | #ifndef TELEGRAMBYLEO_SRC_BASE_DEF_MQH
|
| | | #define TELEGRAMBYLEO_SRC_BASE_DEF_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | #include <TSN\\Json\\Json.mqh>
|
2026-09-24 09:25:09 -05:00 | | | #include <TSN\\WebUtils\\Multipart.mqh>
|
2026-09-23 16:35:15 -05:00 | | | #include "..\\..\\EnumReg\\Main.mqh"
|
2026-09-25 16:54:01 -05:00 | | | #include <TSN\\MQLArticles\\Utils\\FA\\Str\\Fixed.mqh>
|
2026-09-22 17:06:21 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | namespace TSN
|
| | | {
|
| | | //+------------------------------------------------------------------+
|
2026-09-23 15:26:06 -05:00 | | | //| End points |
|
2026-09-22 17:06:21 -05:00 | | | //+------------------------------------------------------------------+
|
| | | #define TELEGRAMBYLEO_BASE_URL "https://api.telegram.org"
|
| | |
|
2026-09-23 21:33:46 -05:00 | | | //- Updates
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETUPDATES "getUpdates"
|
| | |
|
2026-09-24 13:22:43 -05:00 | | | //- Me
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETME "getMe"
|
| | |
|
2026-09-23 15:26:06 -05:00 | | | //- Send
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDMESSAGE "sendMessage"
|
2026-09-26 16:42:14 -05:00 | | | #define TELEGRAMBYLEO_ENDPOINT_SENDRICHMESSAGE "sendRichMessage"
|
2026-09-23 15:26:06 -05:00 | | | #define TELEGRAMBYLEO_ENDPOINT_SENDCHATACTION "sendChatAction"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDPOLL "sendPoll"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDDOC "sendDocument"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDVIDEO "sendVideo"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDAUDIO "sendAudio"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDVOICE "sendVoice"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDANIMATION "sendAnimation"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SENDPHOTO "sendPhoto"
|
| | |
|
| | | //- Reacciones
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETMESSAGEREACTION "setMessageReaction"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_DELMESSAGEREACTION "deleteMessageReaction"
|
| | |
|
| | | //- Miembros
|
| | | #define TELEGRAMBYLEO_ENDPOINT_BANCHATMEMBER "banChatMember"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_UNBANCHATMEMBER "unbanChatMember"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_RESTRICTCHATMEMBER "restrictChatMember"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_PROMOTECHATMEMBER "promoteChatMember"
|
| | |
|
| | | //- Yo (perfil del bot)
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETMYPROFILEPHOTO "setMyProfilePhoto"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_REMOVEMYPROFILEPHOTO "removeMyProfilePhoto"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETMYNAME "setMyName"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETMYNAME "getMyName"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETMYDESCRIPTION "setMyDescription"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETMYDESCRIPTION "getMyDescription"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETMYSHORTDESC "setMyShortDescription"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETMYSHORTDESC "getMyShortDescription"
|
| | |
|
| | | //- Chat
|
| | | #define TELEGRAMBYLEO_ENDPOINT_DELCHATPHOTO "deleteChatPhoto"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETCHATPHOTO "setChatPhoto"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETCHATTITLE "setChatTitle"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETCHATDESCRIPTION "setChatDescription"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_PINCHATMESSAGE "pinChatMessage"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_UNPINCHATMESSAGE "unpinChatMessage"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_UNPINALLCHATMSGS "unpinAllChatMessages"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_LEAVECHAT "leaveChat"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETCHAT "getChat"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETCHATADMINS "getChatAdministrators"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETCHATMEMBERCOUNT "getChatMemberCount"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_GETCHATMEMBER "getChatMember"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_SETCHATSTICKERSET "setChatStickerSet"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_DELCHATSTICKERSET "deleteChatStickerSet"
|
| | |
|
| | | //- Botones / callback
|
| | | #define TELEGRAMBYLEO_ENDPOINT_ANSWERCALLBACKQUERY "answerCallbackQuery"
|
| | |
|
| | | //- Poll
|
| | | #define TELEGRAMBYLEO_ENDPOINT_STOPPOLL "stopPoll"
|
| | |
|
| | | //- Delete
|
| | | #define TELEGRAMBYLEO_ENDPOINT_DELMESSAGE "deleteMessage"
|
2026-09-22 17:06:21 -05:00 | | |
|
2026-09-25 21:10:24 -05:00 | | | //- Edicion
|
2026-09-26 16:42:14 -05:00 | | | #define TELEGRAMBYLEO_ENDPOINT_EDITMESSAGETEXT "editMessageText"
|
| | | #define TELEGRAMBYLEO_ENDPOINT_EDITMESSAGEREPLYMARKUP "editMessageReplyMarkup"
|
2026-09-25 21:10:24 -05:00 | | |
|
2026-09-22 17:06:21 -05:00 | | | //+------------------------------------------------------------------+
|
2026-09-23 15:26:06 -05:00 | | | //| Eventos |
|
| | | //+------------------------------------------------------------------+
|
| | | enum ENUM_TELEGRAMBYLEO_GETUPT_KEYVALUE
|
| | | {
|
| | | //---
|
2026-09-23 16:35:15 -05:00 | | | TELEGRAMBYLEO_GETUPT_K_UPDATEID,
|
2026-09-23 15:26:06 -05:00 | | |
|
| | | //---
|
2026-09-23 16:35:15 -05:00 | | | TELEGRAMBYLEO_GETUPT_K_MESSAGE,
|
| | | TELEGRAMBYLEO_GETUPT_K_EDITED_MESSAGE,
|
| | | TELEGRAMBYLEO_GETUPT_K_CHANNEL_POST,
|
| | | TELEGRAMBYLEO_GETUPT_K_EDITED_CHANNEL_POST,
|
| | | TELEGRAMBYLEO_GETUPT_K_BUSINESS_CONNECTION,
|
| | | TELEGRAMBYLEO_GETUPT_K_BUSINESS_MESSAGE,
|
| | | TELEGRAMBYLEO_GETUPT_K_EDITED_BUSINESS_MESSAGE,
|
| | | TELEGRAMBYLEO_GETUPT_K_DELETED_BUSINESS_MESSAGES,
|
| | | TELEGRAMBYLEO_GETUPT_K_GUEST_MESSAGE,
|
| | | TELEGRAMBYLEO_GETUPT_K_MESSAGE_REACTION,
|
| | | TELEGRAMBYLEO_GETUPT_K_MESSAGE_REACTION_COUNT,
|
| | | TELEGRAMBYLEO_GETUPT_K_INLINE_QUERY,
|
| | | TELEGRAMBYLEO_GETUPT_K_CHOSEN_INLINE_RESULT,
|
| | | TELEGRAMBYLEO_GETUPT_K_CALLBACK_QUERY,
|
| | | TELEGRAMBYLEO_GETUPT_K_SHIPPING_QUERY,
|
| | | TELEGRAMBYLEO_GETUPT_K_PRE_CHECKOUT_QUERY,
|
| | | TELEGRAMBYLEO_GETUPT_K_PURCHASED_PAID_MEDIA,
|
| | | TELEGRAMBYLEO_GETUPT_K_POLL,
|
| | | TELEGRAMBYLEO_GETUPT_K_POLL_ANSWER,
|
| | | TELEGRAMBYLEO_GETUPT_K_MY_CHAT_MEMBER,
|
| | | TELEGRAMBYLEO_GETUPT_K_CHAT_MEMBER,
|
| | | TELEGRAMBYLEO_GETUPT_K_CHAT_JOIN_REQUEST,
|
| | | TELEGRAMBYLEO_GETUPT_K_CHAT_BOOST,
|
| | | TELEGRAMBYLEO_GETUPT_K_REMOVED_CHAT_BOOST,
|
| | | TELEGRAMBYLEO_GETUPT_K_MANAGED_BOT,
|
| | | TELEGRAMBYLEO_GETUPT_K_SUBSCRIPTION,
|
| | | TELEGRAMBYLEO_GETUPT_K_STOPPED_MESSAGE_GENERATION,
|
2026-09-23 15:26:06 -05:00 | | |
|
| | | //---
|
2026-09-24 12:18:36 -05:00 | | | TELEGRAMBYLEO_GETUPT_K_TOTAL
|
2026-09-23 15:26:06 -05:00 | | | };
|
2026-09-24 12:18:36 -05:00 | | |
|
| | | //---
|
| | | const string g_tlgbyleo_getupt_kstr[TELEGRAMBYLEO_GETUPT_K_TOTAL - 1] =
|
| | | {
|
| | | "message",
|
| | | "edited_message",
|
| | | "channel_post",
|
| | | "edited_channel_post",
|
| | | "business_connection",
|
| | | "business_message",
|
| | | "edited_business_message",
|
| | | "deleted_business_messages",
|
| | | "guest_message",
|
| | | "message_reaction",
|
| | | "message_reaction_count",
|
| | | "inline_query",
|
| | | "chosen_inline_result",
|
| | | "callback_query",
|
| | | "shipping_query",
|
| | | "pre_checkout_query",
|
| | | "purchased_paid_media",
|
| | | "poll",
|
| | | "poll_answer",
|
| | | "my_chat_member",
|
| | | "chat_member",
|
| | | "chat_join_request",
|
| | | "chat_boost",
|
| | | "removed_chat_boost",
|
| | | "managed_bot",
|
2026-09-25 21:10:24 -05:00 | | | "subscription",
|
| | | "stopped_message_generation"
|
2026-09-24 12:18:36 -05:00 | | | };
|
| | |
|
2026-09-23 15:26:06 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Basicos |
|
2026-09-22 17:06:21 -05:00 | | | //+------------------------------------------------------------------+
|
| | | enum ENUM_TELEGRAMBYLEO_CHAT_ACTION
|
| | | {
|
| | | TELEGRAMBYLEO_CHAT_ACTION_TYPING,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_UPLOAD_PHOTO,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_RECORD_VIDEO,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_UPLOAD_VIDEO,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_RECORD_AUDIO,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_UPLOAD_AUDIO,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_UPLOAD_DOCUMENT,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_CHOOSE_STIKER,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_FIND_LOCATION,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_RECORD_VIDEO_NOTE,
|
| | | TELEGRAMBYLEO_CHAT_ACTION_UPLOAD_VIDEO_NOTE
|
| | | };
|
| | |
|
| | | //---
|
| | | enum ENUM_TELEGRAM_PARSE_MODE
|
| | | {
|
| | | TELEGRAM_PARSE_MODE_HTML = 0,
|
| | | TELEGRAM_PARSE_MODE_MD = 1,
|
| | | TELEGRAM_PARSE_MODE_MD_2 = 2
|
| | | };
|
| | |
|
| | |
|
| | | //---
|
2026-09-25 22:28:13 -05:00 | | | const CStringFixed<MQLA_B(16)> g_telegram_parse_mode_str[3] =
|
2026-09-22 17:06:21 -05:00 | | | {
|
2026-09-25 22:28:13 -05:00 | | | {{'H', 'T', 'M', 'L'}, 4}, // HTML
|
| | | {{'M', 'a', 'r', 'k', 'd', 'o', 'w', 'n'}, 8}, // Markdown
|
| | | {{'M', 'a', 'r', 'k', 'd', 'o', 'w', 'n', 'V', '2'}, 10} // MarkdownV2
|
2026-09-22 17:06:21 -05:00 | | | };
|
| | |
|
| | | //---
|
2026-09-25 22:28:13 -05:00 | | | const CStringFixed<MQLA_B(32)> g_telegram_chat_action[] =
|
2026-09-22 17:06:21 -05:00 | | | {
|
2026-09-25 22:28:13 -05:00 | | | {{'t', 'y', 'p', 'i', 'n', 'g'}, 6}, // typing
|
| | | {{'u', 'p', 'l', 'o', 'a', 'd', '_', 'p', 'h', 'o', 't', 'o'}, 12}, // upload_photo
|
| | | {{'r', 'e', 'c', 'o', 'r', 'd', '_', 'v', 'i', 'd', 'e', 'o'}, 12}, // record_video
|
| | | {{'u', 'p', 'l', 'o', 'a', 'd', '_', 'v', 'i', 'd', 'e', 'o'}, 12}, // upload_video
|
| | | {{'r', 'e', 'c', 'o', 'r', 'd', '_', 'v', 'o', 'i', 'c', 'e'}, 12}, // record_voice
|
| | | {{'u', 'p', 'l', 'o', 'a', 'd', '_', 'v', 'o', 'i', 'c', 'e'}, 12}, // upload_voice
|
| | | {{'u', 'p', 'l', 'o', 'a', 'd', '_', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't'}, 15}, // upload_document
|
| | | {{'c', 'h', 'o', 'o', 's', 'e', '_', 's', 't', 'i', 'c', 'k', 'e', 'r'}, 14}, // choose_sticker
|
| | | {{'f', 'i', 'n', 'd', '_', 'l', 'o', 'c', 'a', 't', 'i', 'o', 'n'}, 13}, // find_location
|
| | | {{'r', 'e', 'c', 'o', 'r', 'd', '_', 'v', 'i', 'd', 'e', 'o', '_', 'n', 'o', 't', 'e'}, 17}, // record_video_note
|
| | | {{'u', 'p', 'l', 'o', 'a', 'd', '_', 'v', 'i', 'd', 'e', 'o', '_', 'n', 'o', 't', 'e'}, 17} // upload_video_note
|
2026-09-22 17:06:21 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Error |
|
| | | //+------------------------------------------------------------------+
|
| | | enum ENUM_TELEGRAMBYLEO_ERR
|
| | | {
|
2026-09-23 17:35:51 -05:00 | | | TELEGRAMBYLEO_ERR_NOT,
|
2026-09-22 17:06:21 -05:00 | | | TELEGRAMBYLEO_ERR_TOKEN_EMPTY,
|
| | | TELEGRAMBYLEO_ERR_JSON_PARSING,
|
| | | TELEGRAMBYLEO_ERR_JSON_NOT_OK,
|
| | | TELEGRAMBYLEO_ERR_WEB_REQ,
|
| | | };
|
| | |
|
| | | //---
|
| | | }
|
| | | #endif // TELEGRAMBYLEO_SRC_BASE_DEF_MQH
|