Discussion of article "How to create bots for Telegram in MQL5" - page 49

 
Vladimir Pastushak #:

I understand it, but I don't know how to implement it. Is there a code example?

https://api.telegram.org/bot{token bot}/deleteWebhook
In the browser do once like this https://api.telegram.org/bot856203438:AAG1IDoQ_Fey5Wu88Jo-_YKCYIaeEnVxmRs/deleteWebhook
 
Sergey Zhilinskiy #:
In the browser do one time like this https://api.telegram.org/bot856203438:AAG1IDoQ_Fey5Wu88Jo-_YKCYIaeEnVxmRs/deleteWebhook

Thank you! I think that's enough.

 
Sergey Zhilinskiy #:
In the browser do one time like this https://api.telegram.org/bot856203438:AAG1IDoQ_Fey5Wu88Jo-_YKCYIaeEnVxmRs/deleteWebhook

It didn't work, can you show the code or what needs to be done? I'm not good with telegram bots unfortunately.....

 
Vladimir Pastushak #:

It didn't work, can you show me the code or what needs to be done? I'm not good with telegram bots unfortunately.....

write your own, without the bible, it's very simple.

There is also written how to overcome this feature.

https://tlgrm.ru/docs/bots/api

Справочник по Telegram Bot API
Справочник по Telegram Bot API
  • tlgrm.ru
Методы и объекты Bot API в Telegram.
 
Webrequest_dll.mqh POST requests don't work (((
 

Simple code, but sending a photo file doesn't work

//+------------------------------------------------------------------+

//|5555.mq4 |

//| Copyright 2022, MetaQuotes Software Corp. | |

//| https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property strict
#include <Telegram.mqh>
/--- Input parameters
const string TelegramBotToken = "5499894508:AAGQFdha3N84sPsIPAw2Sfb-kGSnpdMKQWER";
const long ChatId           = -1001682411943;
const string InpChannelName = "@************";
const string TelegramApiUrl   = "https://api.telegram.org"; // Add this to Allow URLs
//--- Global variables
CCustomBot bot;
int getme_result;
//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
  {
//--- SET TOKEN
   bot.Token(TelegramBotToken);
//--- check token
   getme_result=bot.GetMe();
//--- run timer
   EventSetTimer(3);
   OnTimer();
//---DONE.

//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialisation function|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
  //+------------------------------------------------------------------+
//| OnTimer|
//+------------------------------------------------------------------+
void OnTimer()
  {
//--- show error message end exit
   if(getme_result!=0)
     {
      Comment("Error: ",GetErrorDescription(getme_result));
      return;
     }
//--- show bot name
   Comment("Bot name: ",bot.Name());
//---{ insert your code here }
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert tick function|
//+------------------------------------------------------------------+
void OnTick()
  {
//---
int res=bot.SendMessage(InpChannelName,"Running a test " +TimeToString(TimeCurrent()));
int ac=bot.SendChatAction(InpChannelName,ACTION_UPLOAD_PHOTO);
string filepath = "C:\mypic.gif";
string photo_id;
int pic=bot.SendPhoto(photo_id,InpChannelName,filepath); 
  }
//+------------------------------------------------------------------+


Messages come in with no problem, photo is not sending. Help to solve the problem


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2022.12.11
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
sportoman #:

Simple code, but sending a photo file doesn't work

Messages come in with no problem, photo is not sending. Help to solve the problem

You have messed up the paths. Take here the path where you save

 
It's not a path error. It's a Webrequest error. I've tried everything, no matter where I saved the file.
 
sportoman Webrequest error. I've tried everything, no matter where I saved the file.

This function works in the sandbox. Only inside the files directory of the metatrader terminal.

I use this code myself, the code works

 
Vladimir Pastushak #:

This function works in the sandbox. Only inside the files directory of the metatrader terminal.

I use this code myself, the code works

Indeed, I removed the path, left the file name and started sending from MQL4\Files. Thank you.


One more question - how to pass HTML text formatting to the Telegram bot?