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

 
Andrey Khatimlianskii:

If the bot is in the channel and has permission to send messages, you can.

The bot is added to the channel administrators and has the right to send messages. It sends messages to the public channel, but as soon as I make it private, it starts writing "Bad request". I understand that I need to substitute the link to the channel (for the public version) with a link to the private version of the channel...? Or how to do it correctly?

 
Yevhenii Levchenko:

The bot is added to the channel administrators and has the right to send messages. It sends messages to the public channel, but as soon as I make it private, it starts writing "Bad request". I understand that I need to substitute the link to the channel (for the public version) with a link to the private version of the channel...? Or how to do it correctly?

Are you talking about the private channel?
 
Aleksei Beliakov:
You mean the private channel?

Yes

 
you can send it, send it by channel id.
 
Aleksei Beliakov:
you can send it, send it by channel id.
Thank you very much!
 

Sometimes, when trying to send a screenshot of a graph, it says: "Error: Unknown error 5020" - the file does not exist. Although it is present in the Files folder. This happens sometimes. Sometimes it publishes everything in a row (I make more than 3 seconds delay between sending messages). The algorithm itself looks as follows: the bot opens a chart, moves the chart to the rightmost position, creates arrows (price levels), takes a screenshot, sends it (after sending a delay of 3 seconds just ... without it for some reason does not want to send it), deletes the arrows and after checking for the presence of the file deletes it. Or does not delete it. If the bot gives error 5020 when sending, the FileIsExist function returns nonsense. I tried to set delays after file creation, but it didn't help much. I send to an open channel. The extension is .gif.

How bad is this solution (sending screenshots like this)? The code is probably far from ideal, but why doesn't it want to send screenshots? Or rather, sometimes it sends them normally, and sometimes it doesn't want to send them at all. Internet seems to be normal...

 if(ScreenShotsAllowed) {
               long chartID = ChartOpen(symbolName,PERIOD_CURRENT);

               ResetLastError();
               if(!ChartNavigate(chartID,CHART_CURRENT_POS,WindowFirstVisibleBar())) {
                  Print ("Error at ChartNavigate: ", GetLastError());
               }

               createArrow(chartID,SymbolInfoDouble(symbolName,SYMBOL_BID),Time[0],BuyArrowCode,arrowBuy,clrDarkSlateGray);
               createArrow(chartID,SymbolInfoDouble(symbolName,SYMBOL_BID)+candleSize[i]*Target_1,Time[0],Target_1_Code,target_1,TpTargetColor);
               createArrow(chartID,SymbolInfoDouble(symbolName,SYMBOL_BID)+candleSize[i]*Target_2,Time[0],Target_2_Code,target_2,TpTargetColor);
               createArrow(chartID,SymbolInfoDouble(symbolName,SYMBOL_BID)+candleSize[i]*Target_3,Time[0],Target_3_Code,target_3,TpTargetColor);
               createArrow(chartID,low[i]-bufferSell[i],iTime(symbolName,PERIOD_CURRENT,0),SlCode,sl,SlTargetColor);

               ResetLastError();
               string filename = symbolName+fileExtension;
               PrintFormat("Filename: %s",filename);
               if(!ChartScreenShot(chartID,filename,(int)ChartGetInteger(chartID,CHART_WIDTH_IN_PIXELS,0),
                                   (int)ChartGetInteger(chartID,CHART_HEIGHT_IN_PIXELS,0),ALIGN_RIGHT)) {
                  Print ("Error at ChartScreenShot: ", GetLastError());
               } else {

                  string photo_id;
                  int result=bot.SendPhoto(photo_id,InpChannelName,filename,"screenshot");

                  if(result==0) {
                     Sleep(Delay);
                     Print("Photo ID: ",photo_id);
                     deleteObjects(chartID);
                  } else
                     Print("Error: ",GetErrorDescription(result));
                  if(FileIsExist(filename)) {
                     ResetLastError();
                     if(!FileDelete(filename)) {
                        PrintFormat("Cant delete file: %s, err code: %d",filename,GetLastError());
                     }else
                     PrintFormat("Deleted file: %s",filename);
                  }
               }

               ChartClose(chartID);
            }
 
Yevhenii Levchenko:

Sometimes, when trying to send a screenshot of a graph, it says: "Error: Unknown error 5020" - the file does not exist. Although it is present in the Files folder. This happens sometimes. Sometimes it publishes everything in a row (I make more than 3 seconds delay between sending messages). The algorithm itself looks as follows: the bot opens a chart, moves the chart to the rightmost position, creates arrows (price levels), takes a screenshot, sends it (after sending a delay of 3 seconds just ... without it for some reason does not want to send it), deletes the arrows and after checking for the presence of the file deletes it. Or does not delete it. If the bot gives error 5020 when sending, the FileIsExist function returns nonsense. I tried to set delays after file creation, but it didn't help much. I send to an open channel. The extension is .gif.

How bad is this solution (sending screenshots like this)? The code is probably far from ideal, but why doesn't it want to send screenshots? Or rather, sometimes it sends them normally, and sometimes it doesn't want to send them at all. Internet seems to be normal...

Look, there was a discussion.

The file does not have time to record, you need to wait.

 

I use Chat_ID and i type the 2 link in the MT5, but still has error 

"Error: Unknown error 1001"

Can anyone know what wrong? Please help



 
To Pui Kuen:

Thanks, how can i get the chat_id ?

forward message from private channel to @getidsbot

 
I have this error:

'SendPhoto' - no one of the overloads can be applied to the function call Telegram_Bot_EA.mq5 117 24


When compiling telegram_bot MT5