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

 
Do you have any idea how to add Inline Keyboard function in this?
 
int OnInit()
  {
   string fileType = "png";
   string fileName = "MewPhoto." + fileType;
   ChartScreenShot(0, fileName, 900, 900, ALIGN_RIGHT);
   Sleep(50);
   bot.Token(Token);
   int result = bot.GetMe();
   bot.GetUpdates();
   Comment("Bot Name ",bot.Name());
   bot.SendChatAction(int(ChatId),ACTION_UPLOAD_PHOTO);
   Sleep(500);
   if(FileIsExist(fileName))
     {
      string photo_id;
      result=bot.SendPhoto(photo_id,ChatId,fileName,"Hello");
     }
   if(!FileIsExist(fileName))
     {Alert("Image not find");}
//   EventSetTimer(60);

//---
   return(INIT_SUCCEEDED);
  }
Anyone SendPhoto success! Please Help me! There no picture send to Telegram
 
Cerilo Cabacoy #:

Hi everyone,

I am trying to send a message from MT5 to Telegram using a bot. However, I could not send the message from MT5 to Telegram due to the error: 

'Error Code 400 Description "Bad request: chat not found"

Has anyone encountered the same problem? Can you give some reasons why this error might have occurred?

I did a lot of research online, but I could not get the right answers.


I have just got the same error" Error Code 400 Description "Bad request: chat not found" but everything worked perfectly before. I also did some research & havent found any solution.

Could anyone shed me some light how to fix this problem? Thanks

#include <Telegram.mqh>
//--- input parameters
input string InpToken="7504821711:AAFljwzACG8ezAhRXzDB2iU9BDM5p0VTDKs";
input string InpChannelName="Test_Error_SendMessage";//Channel Name
//--- global variables
CCustomBot bot;
int OnInit()
  {
//--- set token
   bot.Token(InpToken);  
  //--- 
   return(INIT_SUCCEEDED);
  }
////  Press "A" on keyboard to test & get the error: "Error Code 400 Description "Bad request: chat not found"
void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
    {
        if (id== CHARTEVENT_KEYDOWN && lparam == StringGetChar("A",0)){
        const string msg = bot.Name();
        // send msg
        int res=bot.SendMessage(InpChannelName,msg);
        if(res!=0) Print("Error: ",GetErrorDescription(res));  
        }               
    }
void OnTick()
  {
  return;
  }    
void OnDeinit(const int reason)
  {
  return;
  }
// end test
 
aphong #:

I have just got the same error" Error Code 400 Description "Bad request: chat not found" but everything worked perfectly before. I also did some research & havent found any solution.

Could anyone shed me some light how to fix this problem? Thanks

in my case, I just read old posts & know that im trying to send msg to a private channel. So I have just replaced the channel name with chat id & its working perfectly!

Thanks  Andriy & other pro coders <3

Andriy Voitenko
Andriy Voitenko
  • 2023.07.11
  • www.mql5.com
Trader's profile
 
Canyou explain how I can read messages from my own telegram channel? There is a bot connected as an admin to this channel, but the text of the message can not pull out. Would you be kind enough to give me a hint?
 

Hello, everybody.

Start of this week the file Telegram.mqh is giving some issues with the functions "ArrayAdd" and "WebRequest".

Is someone also facing this problems? I tried adding back the original files, but they seem to have the same issue as well.

Thank you and best regards,

Henrique

-------------------------------------------------------------------------------------

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 149 10

could be one of 2 function(s) Telegram.mqh 149 10

   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22

   void CCustomBot::ArrayAdd(char&[],const string) Telegram.mqh 132 22

'WebRequest' - no one of the overloads can be applied to the function call Telegram.mqh 230 15

could be one of 2 function(s) Telegram.mqh 230 15

   built-in: int WebRequest(const string,const string,const string,const string,int,const char&[],int,char&[],string&) Telegram.mqh 230 15

   built-in: int WebRequest(const string,const string,const string,int,const char&[],char&[],string&) Telegram.mqh 230 15

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 737 7

could be one of 2 function(s) Telegram.mqh 737 7

   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22

   void CCustomBot::ArrayAdd(char&[],const string) Telegram.mqh 132 22

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 738 7

could be one of 2 function(s) Telegram.mqh 738 7

   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22


 
Henrique Felipini #:

Hello, everybody.

Start of this week the file Telegram.mqh is giving some issues with the functions "ArrayAdd" and "WebRequest".

Is someone also facing this problems? I tried adding back the original files, but they seem to have the same issue as well.

Thank you and best regards,

Henrique

-------------------------------------------------------------------------------------

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 149 10

could be one of 2 function(s) Telegram.mqh 149 10

   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22

   void CCustomBot::ArrayAdd(char&[],const string) Telegram.mqh 132 22

'WebRequest' - no one of the overloads can be applied to the function call Telegram.mqh 230 15

could be one of 2 function(s) Telegram.mqh 230 15

   built-in: int WebRequest(const string,const string,const string,const string,int,const char&[],int,char&[],string&) Telegram.mqh 230 15

   built-in: int WebRequest(const string,const string,const string,int,const char&[],char&[],string&) Telegram.mqh 230 15

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 737 7

could be one of 2 function(s) Telegram.mqh 737 7

   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22

   void CCustomBot::ArrayAdd(char&[],const string) Telegram.mqh 132 22

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 738 7

could be one of 2 function(s) Telegram.mqh 738 7

   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22


try with this file

Files: