文章 "如何采用 MQL5 创建用于 Telegram 的 bots" - 页 55

 
您知道如何在其中添加内联键盘功能吗?
 
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);
  }
有人发送照片成功!请帮助我!没有图片发送到 Telegram
 
Cerilo Cabacoy 错误代码 400 描述 "错误请求:未找到聊天"

有人遇到过同样的问题吗?您能解释一下为什么会出现这种错误吗?

我在网上查了很多资料,但都没有得到正确的答案。


我刚刚也遇到了同样的错误 "错误代码400 描述 "错误请求:未找到聊天",但之前一切正常。我也做了一些研究,但没有找到任何解决方案。

谁能告诉我如何解决这个问题?谢谢

#include <Telegram.mqh>
//--- 输入参数
input string InpToken="7504821711:AAFljwzACG8ezAhRXzDB2iU9BDM5p0VTDKs";
input string InpChannelName="Test_Error_SendMessage";//Channel Name
//--- 全局变量
CCustomBot bot;
int OnInit()
  {
//--- 设置标记
   bot.Token(InpToken);  
  //--- 
   return(INIT_SUCCEEDED);
  }
//// 按键盘上的 "A "键测试并得到错误信息:"错误代码 400 描述 "错误请求:未找到聊天"。
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();
        // 发送信息
        int res=bot.SendMessage(InpChannelName,msg);
        if(res!=0) Print("Error: ",GetErrorDescription(res));  
        }               
    }
void OnTick()
  {
  return;
  }    
void OnDeinit(const int reason)
  {
  return;
  }
// 结束测试
 
aphong 错误代码400 描述 "错误请求:未找到聊天",但之前一切正常。我也做了一些研究,但没有找到任何解决方案。

谁能告诉我如何解决这个问题?谢谢

在我的情况下,我只是阅读了以前的帖子,知道我正试图向一个私人频道发送信息。所以我用聊天 ID 替换了频道名称,结果效果非常好!

感谢Andriy 和其他专业程序员 <3

Andriy Voitenko
Andriy Voitenko
  • 2023.07.11
  • www.mql5.com
Trader's profile
 
能解释一下如何读取我自己的电报频道的消息吗?有一个机器人以管理员身份连接到了这个频道,但无法读取信息文本。您能给我一点提示吗?
 

本周开始,Telegram.mqh 文件中的函数 "ArrayAdd "和 "WebRequest "出现了一些问题。

有人也遇到过这种问题吗?我试着添加回原始文件,但它们似乎也有同样的问题。

'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 # 本周开始,Telegram.mqh 文件中的函数 "ArrayAdd "和 "WebRequest "出现了一些问题。有人也遇到过这种问题吗?我试着添加回原始文件,但它们似乎也有同样的问题。

试试这个文件

附加的文件:
 
Lorentzos Roussos #:

试试这个文件

我收到了一些错误信息,因此进行了 4 次编辑

      while(::StringReplace(text,"  "," ")>0);
      ::StringReplace(text,";"," ");
      ::StringReplace(text,","," ");
 
just these and another string function as well 
附加的文件:
Telegram.mqh  85 kb