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

 

Has anybody tried BOLD or ITALIC fonts using this library?
I have tried **bold** __italic__ with markdown in the message as follows but no cigar...


"n**boldtext** __italictext__ Balance: $%s parse_mode=MARKDOWN"

The result is: 

**boldtext** __italictext__ Balance: $10056.21 parse_mode=MARKDOWN
 

Never mind....

I found the answer by setting AsHTML flag to true...

bot.SendMessage(InpTelegramId,"<b>Balance: $10056.21</b>",true);

Sorry...


spottypegasus:

Has anybody tried BOLD or ITALIC fonts using this library?
I have tried **bold** __italic__ with markdown in the message as follows but no cigar...


"n**boldtext** __italictext__ Balance: $%s parse_mode=MARKDOWN"

The result is: 

**boldtext** __italictext__ Balance: $10056.21 parse_mode=MARKDOWN
 

Hi all,

Maybe some of you can help, I'm desperately trying to find a solution to send a local screenshot via MT4 to Telegram.

Quick code snipped

int res=bot.SendMessage(-100135482xxx,"Running a test " +TimeToString(TimeCurrent()));
int ac=bot.SendChatAction(-100135482xxx,ACTION_UPLOAD_PHOTO);
int pic=bot.SendPhoto(filepath+"\mypic.gif",-100135482xxx,filepath);

First one works, as I'm getting the message, even if I use @channelname

Second one works only with chatID, which is ok, I can live with it

Third one is throwing me the error:

2020.08.07 21:40:15.175 xxx1: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

Any idea, what I'm doing wrong?


 
Tomasz Maria Burzanowski:

Hi all,

Maybe some of you can help, I'm desperately trying to find a solution to send a local screenshot via MT4 to Telegram.

Quick code snipped

First one works, as I'm getting the message, even if I use @channelname

Second one works only with chatID, which is ok, I can live with it

Third one is throwing me the error:

2020.08.07 21:40:15.175 xxx1: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}

Any idea, what I'm doing wrong?


yes you have to modify the mqh file so that it accepts that negative number.

 

@Marco vd Heijden thanks!

This is interesting I had a look at Telegram.mqh and I see three functions for SendPhoto, out of which I'm wondering how the code knows which one to use. The third one is anyway out of the question.


First:

   int SendPhoto(string &_photo_id,
                 const long _chat_id,
                 const string _local_path,
                 const string _caption=NULL,
                 const bool _common_flag=false,
                 const int _timeout=10000)

Second:

int SendPhoto(string &_photo_id,
                 const string _channel_name,
                 const string _local_path,
                 const string _caption=NULL,
                 const bool _common_flag=false,
                 const int _timeout=10000)

Could it be that the code does not know which one I want to take? I'm trying to trigger the first one, but actually the second one would be better.

Secondly I tried to search in the first function what is happening with _chat_id, but I can only see a simple integer to string conversion:

ArrayAdd(data,"\r\n");
      ArrayAdd(data,"--"+hash+"\r\n");
      ArrayAdd(data,"Content-Disposition: form-data; name=\"chat_id\"\r\n");
      ArrayAdd(data,"\r\n");
      ArrayAdd(data,IntegerToString(_chat_id));
      ArrayAdd(data,"\r\n");
 
Tomasz Maria Burzanowski:

notice second parameter one is a long the other is a string

 const long _chat_id,

and 

const string _channel_name,

this is part of mql basics u can have million functions with the same name with different parameters or number of parameters 

 

@Jefferson Metha yes I do understand that, it was just my thought, as it's been so tough to find the issues.

I used now the tips described in https://www.mql5.com/en/forum/89826/page15#comment_17079865, but still not getting anywhere.

I'd like to focus on the sendPhoto function where the input is Channel name, not chat ID, so let's solely focus on one thing.


What I did so far, in Telegarm.mqh in the function

   int SendPhoto(string &_photo_id,
                 const string _channel_name,
                 const string _local_path,
                 const string _caption=NULL,
                 const bool _common_flag=false,
                 const int _timeout=10000)

I've modified the following line:

      string name=StringTrim(_channel_name);
      name=_channel_name;
      /*if(StringGetCharacter(name,0)!='@') TB 09.08
         name="@"+name;*/

Basically removing the StringTrim function, but it's not getting better.

Discussion of article "How to create bots for Telegram in MQL5"
Discussion of article "How to create bots for Telegram in MQL5"
  • 2020.06.26
  • www.mql5.com
New article How to create bots for Telegram in MQL5 has been published: Author: Andrey Voytenko...
 

Finally figured it out.

Changes:

int SendPhoto(string &_photo_id,
                 const string _channel_name,
                 const string _local_path,
                 const string _caption=NULL,
                 const int _common_flag=0,//Changed to int not bool
                 const int _timeout=10000)

Removed:

string name=StringTrim(_channel_name);
      if(StringGetCharacter(name,0)!='@')
         name="@"+name;

And finally in the EA, as simple as:

string filepath = "mypic.gif";
string photo_id;
int pic=bot.SendPhoto(photo_id,InpChannelName,filepath);
 
Thank you for your effort in composing this article! Extremely helpful for a newbie
 

Hi all,


I dunno if this question have been asked previously, 

I tried this modul with EA format and it works wonderfully, however when i tries this modul with indicator format, it shows an error as below:

2020.08.26 10:25:37.839 inLuk_TelegramBot EURUSD,H1: Error: URL does not allowed for WebRequest


any suggestion ? or this modul can't be work on indicator? 

thanks.

Reason: