記事"MQL5言語でのTelegram用ボットの作成"についてのディスカッション - ページ 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);
  }
どなたかSendPhotoを成功させてください!助けてください!テレグラムに写真が送れません
 
Cerilo Cabacoy エラーコード 400 説明 "不正なリクエスト:チャットが見つかりません"

同じ問題に遭遇した方はいらっしゃいますか?このエラーが発生した理由を教えてください。

私はオンラインで多くの研究をしましたが、私は正しい答えを得ることができませんでした。


エラーコード400 Description "Bad request: chat not found " と表示されました。私はまた、いくつかの研究を行い、任意の解決策を見つけられませんでした。

どなたかこの問題を解決する方法を教えていただけませんか?ありがとうございました。

#include <Telegram.mqh>
//--- 入力パラメータ
input string InpToken="7504821711:AAFljwzACG8ezAhRXzDB2iU9BDM5p0VTDKs";
input string InpChannelName="Test_Error_SendMessage";//チャンネル名
//--- グローバル変数
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();
        // msg を送信する
        int res=bot.SendMessage(InpChannelName,msg);
        if(res!=0) Print("Error: ",GetErrorDescription(res));  
        }               
    }
void OnTick()
  {
  return;
  }    
void OnDeinit(const int reason)
  {
  return;
  }
// テスト終了
 
aphong エラーコード400 説明 "Bad request: chat not found " が表示されました。私はまた、いくつかの研究を行い、任意の解決策を見つけられませんでした。

どなたかこの問題を解決する方法を教えていただけませんか?ありがとうございました。

私の場合、古い投稿を読んで、プライベート・チャンネルにメッセージを送ろうとしていることを知りました。それで、チャンネル名をチャット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