Sending Picture to Telegram

To add comments, please log in or register
Alireza Soleimani Asl
33
Alireza Soleimani Asl  

Hi to all.

I'm trying to make an Expert. In this expert, I'm trying to send a picture to telegram bots.

- But I don't know why it sometimes works and sometimes doesn't works. In other words, sometimes send me the correct pic and sometimes I just see "sending a photo" in Telegram Bot. And I didn't receive anything.

- Surprisingly all pic that iI requested from Bot has saved correctly in "Files" folder

- I used Telegram.mqh and Comment.mqh libs in this Expert.

- I have tried expert with different servers, but the problem still remains.

Where is the problem


int SendScreenShot(const long _chat_id,

                      const string _symbol,

                      const ENUM_TIMEFRAMES _period,

                      const string _template=NULL)

     {

      int result=0;


      long chart_id=ChartOpen(_symbol,_period);

      if(chart_id==0)

         return(ERR_CHART_NOT_FOUND);


      ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true);


      //--- updates chart

      int wait=60;

      while(--wait>0)

        {

         if(SeriesInfoInteger(_symbol,_period,SERIES_SYNCHRONIZED))

            break;

         Sleep(500);

        }


      if(_template!=NULL)

         if(!ChartApplyTemplate(chart_id,_template))

            PrintError(_LastError,InpLanguage);


      ChartRedraw(chart_id);

      Sleep(500);


      ChartSetInteger(chart_id,CHART_SHOW_GRID,false);


      ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false);


      string filename=StringFormat("%s%d.gif",_symbol,_period);


      if(FileIsExist(filename))

         FileDelete(filename);

      ChartRedraw(chart_id);


      Sleep(100);


      if(ChartScreenShot(chart_id,filename,800,600,ALIGN_RIGHT))

        {

         Sleep(100);


         bot.SendChatAction(_chat_id,ACTION_UPLOAD_PHOTO);


         //--- waitng 30 sec for save screenshot

         wait=60;

         while(!FileIsExist(filename) && --wait>0)

            Sleep(500);


         //---

         string screen_id;

         result=bot.SendPhoto(_chat_id,filename,screen_id,_symbol+"_"+StringSubstr(EnumToString(_period),7));

        }


      ChartClose(chart_id);

      return(result);

     }


William Roeder
19999
William Roeder  
Don't paste
code
Play video
Please edit your post.
For large amounts of code, attach it
agsapri
11
agsapri  

more pls 

MaxReneMX
431
MaxReneMX  

Could you solve it, where are the updated libraries?

Marco vd Heijden
Moderator
12423
Marco vd Heijden  
MaxReneMX:

Could you solve it, where are the updated libraries?

You can use the Telegram.mqh 

It was written some time ago so most of it works but not all so for some functionality it will need some slight modifications.

https://www.mql5.com/en/articles/download/2355/telegram.zip

To add comments, please log in or register