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

 
Yevhenii Levchenko:

Each terminal has its own Telegram channel.

I guess the problem is that I don't understand this sentence. I'm not very good with Telegram and channels, can you explain it in a bit more detail?

 
Sergey Kasirenko:

I guess the problem is that I don't understand this sentence. I'm not very good with telegram and channels, can you explain it in a bit more detail.

In Telegram, you can create channels and groups. This is the first one - this is the channel, which is the very channel that we are talking about. Although you can also create a group, I guess...

 
Yevhenii Levchenko:

You can create channels and groups in Telegram. The first one is a channel, which is the very channel we are talking about. Although you can also create a group, I guess...

So, but then how to link groups or channel and the terminal itself? If we address not to a bot by api, but to a group...? I don't understand the structure. Now it is done like this, there is a chatbot, I write a command to it directly, in the terminal by the Expert Advisor it is all caught, but if I put it in another terminal, then of course getUpdates does not work, because there was already one request for this token....

But how else can I get data from the Telegram bot?

 
Sergey Kasirenko:

So, but how can we connect groups or channel and the terminal itself? If we address not the bot by api, but to a group...? I don't understand the structure. Now it is done like this, there is a chatbot, I write a command to it directly, in the terminal it is all caught by the Expert Advisor, but if I put it in another terminal, then of course getUpdates does not work, because there was already one request for this token....

But how else can I get data from the Telegram bot?

You create channels for each terminal. Or groups, you can figure it out yourself. Add your bot as a leader. Collect the channels' icons and put them in an array. Then, when you get a signal, you run through the array and send messages to all the channels. Then you catch updates just like you did with one channel. Only each terminal reads its own channel.

Although I haven't tried it myself).

 
Yevhenii Levchenko:


Haven't tried it that way myself at all though)

That's a strong one )). But thanks anyway, I'll think, dig, try something out

 
Sergey Kasirenko:

Dear forum members, please tell me how to solve this problem

{"ok":false, "error_code":409, "description": "Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"} Who has encountered this? Where to dig, what to look at.

You have some error in the bot logic.

I have many copies running and getting updates every second with no conflicts. It has nothing to do with groups/channels.

Give me some feedback.

 
Andrey Khatimlianskii:

You have some kind of bug in the bot's logic.

I have many copies running and getting updates every second with no conflicts. It has nothing to do with groups/channels.

Give me some feedback.

Thanks for the reply. I did as it was described in the article by Andrey Voitenko. I created a bot, through the token I bound to the messages of this bot and get them using the function getUpdates, I disabled specifically ProcessMessages, in fact, the whole code looks like this:

//+------------------------------------------------------------------+
//| OnTimer|
//+------------------------------------------------------------------+
void OnTimer()
  {
//--- show error message end exit
   if(getme_result!=0)
     {
      comment.SetText(0,"Error: "+GetErrorDescription(getme_result),clrRed);
      if(getme_result==4060) comment.SetText(1,"https://api.telegram.org",clrRed);
      comment.Show();
      return;
     }
//--- show bot name
   //Comment("Bot name: ",bot.Name()));
   if(Flag_Init)
   {
     Flag_Init=false;
     bot.UserNameFilter(sName);
     comment.SetText(0,StringFormat("%s v.%s",EXPERT_NAME,EXPERT_VERSION),clrWhite);
     //comment.SetText(1, "Bot name: "+bot.Name(),clrWhite);
     comment.Show();
   }  
//--- reading messages
   bot.GetUpdates();
//--- processing messages
   //bot.ProcessMessages();
  }
//+------------------------------------------------------------------+

And it turns out that as soon as I put two copies of this bot (now for the simplicity of the experiment in the same terminal), I get this hat:

I understand that it turns out that you can not call the survey with the same token as it seems, because, having read once, it sort of marks that the data is received, and the next copy of the bot will get this error.

But how to organise it differently, I don't know, maybe you have done it differently at all, then share the secret, if it's not a trade secret

 
Sergey Kasirenko:

But how to organise it all differently, I don't know, maybe you have done it differently at all, then share the secret if it's not a trade secret

Commercial, of course )

I wrote to you in a private message

 

Good evening, colleagues.

Could you please tell me how to add smileys to the text of a message?

 
Andrey Kaunov:

Good evening, colleagues.

Could you please tell me how to add smileys to the text of a message?

A real man needs a motorbike and a woman)

Ban again, okay.