Discusión sobre el artículo "Cómo crear un bot para Telegram en el lenguaje MQL5" - página 55

 
¿Tienes alguna idea de cómo añadir la función de teclado en línea en esto?
 
int OnInit()
  {
   string fileType = "png";
   string fileName = "MewPhoto." + fileType;
   ChartScreenShot(0, fileName, 900, 900, ALIGN_RIGHT);
   Sleep(50);
   bot.Token(Token);
   int result = bot.GetMe();
   bot.GetUpdates();
   Comment("Bot Name ",bot.Name());
   bot.SendChatAction(int(ChatId),ACTION_UPLOAD_PHOTO);
   Sleep(500);
   if(FileIsExist(fileName))
     {
      string photo_id;
      result=bot.SendPhoto(photo_id,ChatId,fileName,"Hello");
     }
   if(!FileIsExist(fileName))
     {Alert("Image not find");}
// EventSetTimer(60);

//---
   return(INIT_SUCCEEDED);
  }
¡Cualquiera SendPhoto éxito! ¡Por favor, ayúdenme! No hay foto enviada a Telegram
 
Cerilo Cabacoy 'Código de error 400 Descripción "Solicitud errónea: chat no encontrado"

¿Alguien se ha encontrado con el mismo problema? ¿Podéis dar alguna razón por la que se haya podido producir este error?

He investigado mucho en Internet, pero no he encontrado las respuestas adecuadas.


Acabo de recibir el mismo error" Error Code400 Description "Bad request: chat not found" pero antes todo funcionaba perfectamente. También he investigado y no he encontrado ninguna solución.

¿Podría alguien darme alguna luz cómo solucionar este problema? Gracias

#include <Telegram.mqh>
//--- parámetros de entrada
input string InpToken="7504821711:AAFljwzACG8ezAhRXzDB2iU9BDM5p0VTDKs";
input string InpChannelName="Test_Error_SendMessage";//Nombre del canal
//--- variables globales
CCustomBot bot;
int OnInit()
  {
//--- set token
   bot.Token(InpToken);  
  //--- 
   return(INIT_SUCCEEDED);
  }
//// Pulse "A" en el teclado para probar y obtener el error: "Código de error 400 Descripción "Solicitud errónea: chat no encontrado"
void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
    {
        if (id== CHARTEVENT_KEYDOWN && lparam == StringGetChar("A",0)){
        const string msg = bot.Name();
        // enviar mensaje
        int res=bot.SendMessage(InpChannelName,msg);
        if(res!=0) Print("Error: ",GetErrorDescription(res));  
        }               
    }
void OnTick()
  {
  return;
  }    
void OnDeinit(const int reason)
  {
  return;
  }
// fin de la prueba
 
aphong Error Code400 Description "Bad request: chat not found" pero antes todo funcionaba perfectamente. También he investigado un poco y no he encontrado ninguna solución.

¿Podría alguien darme alguna luz cómo solucionar este problema? Gracias

En mi caso, acabo de leer mensajes antiguos y sé que estoy tratando de enviar msg a un canal privado. ¡Así que he sustituido el nombre del canal con la identificación de chat y su trabajo a la perfección!

Gracias Andriy y otros codificadores pro <3

Andriy Voitenko
Andriy Voitenko
  • 2023.07.11
  • www.mql5.com
Trader's profile
 
¿Pueden explicarme cómo puedo leer los mensajes de mi propio canal de Telegram? Hay un bot conectado como admin a este canal, pero el texto del mensaje no se puede sacar. ¿Sería tan amable de darme una pista?
 

A principios de esta semana el archivo Telegram.mqh está dando algunos problemas con las funciones "ArrayAdd" y "WebRequest".

¿Alguien tiene también estos problemas? He intentado volver a añadir los archivos originales, pero parece que también tienen el mismo problema.

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 149 10
could be one of 2 function(s) Telegram.mqh 149 10
   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22
   void CCustomBot::ArrayAdd(char&[],const string) Telegram.mqh 132 22

'WebRequest' - no one of the overloads can be applied to the function call Telegram.mqh 230 15
could be one of 2 function(s) Telegram.mqh 230 15
   built-in: int WebRequest(const string,const string,const string,const string,int,const char&[],int,char&[],string&) Telegram.mqh 230 15
   built-in: int WebRequest(const string,const string,const string,int,const char&[],char&[],string&) Telegram.mqh 230 15

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 737 7
could be one of 2 function(s) Telegram.mqh 737 7
   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22
   void CCustomBot::ArrayAdd(char&[],const string) Telegram.mqh 132 22

'ArrayAdd' - no one of the overloads can be applied to the function call Telegram.mqh 738 7
could be one of 2 function(s) Telegram.mqh 738 7
   void CCustomBot::ArrayAdd(uchar&[],const uchar&[]) Telegram.mqh 120 22
 
Henrique Felipini # A principios de esta semana el archivo Telegram.mqh está dando algunos problemas con las funciones "ArrayAdd" y "WebRequest". ¿Alguien tiene también estos problemas? He intentado volver a añadir los archivos originales, pero parece que también tienen el mismo problema.

prueba con este archivo

Archivos adjuntos:
 
Lorentzos Roussos #:

prueba con este archivo

Estaba recibiendo algunos errores por lo que hice 4 ediciones

      while(::StringReplace(text,"  "," ")>0);
      ::StringReplace(text,";"," ");
      ::StringReplace(text,","," ");
 
just these and another string function as well 
Archivos adjuntos:
Telegram.mqh  85 kb