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

 
thegosutrader:

Hello,

For those who want to send to a private channel,

1) replace the "@" by "-" in the Telegram.mqh at line 1009 and line 1010 (see attached image),

2) in the mq4 file, you put your channel token starting by -1000xxxx like this: InpChannelName="-10000xxxx";//Channel Name

and you should get the messages after setting your channel to private.

Good luck.

Still does not work ,for inpChannelName do you still use the channel Name or chat ID ?

 
Phindile Victoria Qwabe:

Still does not work ,for inpChannelName do you still use the channel Name or chat ID ?

Chat ID
 

I know this has been asked here before but did not solved.

I get "Error: Unknown error 1001" with this basic code:

//+------------------------------------------------------------------+
//|                                               Telegram_GetMe.mq5 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#include <Telegram.mqh>

input string InpToken="996256588:AAH2yUhFSjexpOUxxj2ZLOmRQXXItAF-B_4";//Token

CCustomBot bot;
int getme_result;
//+------------------------------------------------------------------+
//|   OnInit                                                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- set token
   bot.Token(InpToken);
//--- check token
   getme_result=bot.GetMe();
//--- run timer
   EventSetTimer(3);
   OnTimer();
//--- done
   return(INIT_SUCCEEDED);
  }
//+
.
.
.
.

Would you please tell me what should I do?

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. MQL5 É FRAUDE HÁ MAIS DE 3 MESES COM SALDO...
 

I ask everyone who has error 1001.

Please run this script and paste here the line from the Experts tab with the result.

An example:

2020.06.05 18:06:36.033 WebRequest_Test_Script (EURUSD,H4) Build=2470 WebRequest=1001 GetLastError=5203 strData=

Additionally describe your operating system

Windows 7 7601 SP1

This will help to solve this problem.

 
Andrey Voytenko :

I ask everyone who has error 1001.

Please run this script and paste here the line from the Experts tab with the result.

An example:

2020.06.05 18:06:36.033 WebRequest_Test_Script (EURUSD,H4) Build=2470 WebRequest=1001 GetLastError=5203 strData=

Additionally describe your operating system

Windows 7 7601 SP1

This will help to solve this problem.

thank you sir
you are very kind
:)
wish you a beautiful day

 
Andrey Voytenko:

I ask everyone who has error 1001.

Please run this script and paste here the line from the Experts tab with the result.

An example:

2020.06.05 18:06:36.033 WebRequest_Test_Script (EURUSD,H4) Build=2470 WebRequest=1001 GetLastError=5203 strData=

Additionally describe your operating system

Windows 7 7601 SP1

This will help to solve this problem.

First of all, Thank you Andrey for the reply.

This is the output of my script named "t0.mql5":

2020.06.07 09:27:29.537 t0 (EURUSD,H1)  Build=2475 WebRequest=1001 GetLastError=5203 strData=


  • OS:
     Windows 10 Pro 64 bit
     command line "ver" command returns: Microsoft Windows [Version 10.0.18362.778]
  • Metatrader 5, Build 2475
  • and for "GetLastError=5203" which means HTTP request failed: I have no Firewall Software installed( I just have a free version of bitdefender Antivirus which has never  made a problem).
  • I recheck these things:  1)the token in BotFather, 2) Tools\Options\"Allow web request" and  the relevant addresses. 3) I used a "VPN" service too to check but nothing changed. 4) turned off Windows firewall .
Documentation on MQL5: Network Functions / WebRequest
Documentation on MQL5: Network Functions / WebRequest
  • www.mql5.com
To use the WebRequest() function, add the addresses of the required servers in the list of allowed URLs in the "Expert Advisors" tab of the "Options" window. Server port is automatically selected on the basis of the specified protocol - 80 for "http://" and 443 for "https://". The WebRequest() function is synchronous, which means its breaks the...
 

@aboozar sobboohi Please run this request in command prompt and paste here your result. If you dont have cURL please install from here https://curl.haxx.se/windows/

curl -X POST https://api.telegram.org/bot177791741:AAEcSxsNEu8625Y2I4KAw_H7yGev9tl8uJg/getMe

aboozar sobboohi
aboozar sobboohi
  • www.mql5.com
Trader's profile
 
Andrey Voytenko:

@aboozar sobboohi Please run this request in command prompt and paste here your result. If you dont have cURL please install from here https://curl.haxx.se/windows/

curl -X POST https://api.telegram.org/bot177791741:AAEcSxsNEu8625Y2I4KAw_H7yGev9tl8uJg/getMe

I was not used to curl. it had no "Setup.exe". Just extracted an ran it with both your an my own tokens!

C:\t_SM\Telegram_mql5\curl-7.70.0_1-win64-mingw\curl-7.70.0-win64-mingw\bin>curl -X POST https://api.telegram.org/bot177791741:AAEcSxsNEu8625Y2I4KAw_H7yGev9tl8uJg/getMe
curl: (7) Failed to connect to api.telegram.org port 443: Connection refused

C:\t_SM\Telegram_mql5\curl-7.70.0_1-win64-mingw\curl-7.70.0-win64-mingw\bin>curl -X POST https://api.telegram.org/bot996256588:AAH2yUhFSjexpOUxxj2ZLOmRQXXItAF-B_4/getMe
curl: (7) Failed to connect to api.telegram.org port 443: Connection refused

SOLVED  "Error: Unknown error 1001" =======>  my ISP Problem.

Now I have this outputs from cURL and Webrequest tester:

C:\t_SM\Telegram_mql5\curl-7.70.0_1-win64-mingw\curl-7.70.0-win64-mingw\bin>curl -X POST https://api.telegram.org/bot996256588:AAH2yUhFSjexpOUxxj2ZLOmRQXXItAF-B_4/getMe
{"ok":true,"result":{"id":996256588,"is_bot":true,"first_name":"Signal1","username":"Signal1bot","can_join_groups":true,"can_read_all_group_messages":false,"supports_inline_queries":false}}

"WebRequest_Test_Script.mq5" exexcution result on 'Experts' Tab of Toolbox:
2020.06.07 11:32:23.084 t0 (EURUSD,H1)  Build=2485 WebRequest=200 GetLastError=0 strData={"ok":true,"result":{"id":996256588,"is_bot":true,"first_name":"Signal1","username":"Signal1bot","can_join_groups":true,"can_read_all_group_messages":false,"supports_inline_queries":false}}

Andrey you helped me find it.

 
Andrey Voytenko:

I ask everyone who has error 1001.

Please run this script and paste here the line from the Experts tab with the result.

An example:

2020.06.05 18:06:36.033 WebRequest_Test_Script (EURUSD,H4) Build=2470 WebRequest=1001 GetLastError=5203 strData=

Additionally describe your operating system

Windows 7 7601 SP1

This will help to solve this problem.

I am already test your script in two system

First in windows 7 7601 SP1, running error like  your error
Second in windows 10 pro 64 bit build 18363 running well no error


 

@GedThey MaThey

Please run this request on your Windows 7 7601 SP1 in command prompt and paste here your result. If you dont have cURL please install from here https://curl.haxx.se/windows/

curl -X POST https://api.telegram.org/bot177791741:AAEcSxsNEu8625Y2I4KAw_H7yGev9tl8uJg/getMe

curl for Windows
  • curl.haxx.se
These are the latest and most up to date official curl binary builds for Microsoft Windows. curl version : 7.70.0 Build : 7.70.0_1 Date : 2020-04-29 Changes : 7.70.0 changelog Packages curl for 64 bit Size: 3.2 MB sha256: c9ea2abc80b78e65f9eebe155272c7f27a80a264fe926a398aa5b48d4f5b4e0e curl for 32 bit Size: 3.0 MB sha256...
Reason: