SendPhoto, but there is multiple SendPhoto function in the file, maybe I picked the wrong one?
No it was okay .
#property strict#include <Telegram\TelegramL.mqh>
inputstring channel_name="";//PRIVATE CHANNEL NAME (string)inputstring channel_private_id_string="";//PRIVATE CHANNEL ID (string)string InpToken="";//telegram input token// to get private channel id//Log into Telegram via web: https://web.telegram.org//Find your channel and copy the URL. //You should have something like this: https://web.telegram.org/#/im?p=c**NUMBER**_number//The numbers between "c" and "_" are the ID of your private channel.//Now tell your bot to send the messages to chat_id=-100NUMBER//mql code : /*
id in webtelegram c1334309342_1978467370643286368 >
1334309342 >
-1001334309342 >
string ids="-1001334309342";
long idl=(long)StringToInteger(ids);
bot.SendMessage(idl,messi,NULL,false,false);
*/string private_channel_string_id="";
long private_channel_post_id=0,private_channel_prepost_id=0;
//id of last message for replies long last_message_id=-1;
/*
you can implement a solution where in your trades monitoring class
you maintain the message id that was produced after the trade was posted in the telegram channel
for example ,you open a buy order ,you get its ticket ,you store it in your class array with your trades
myTrades[x].ticket=ticket;
then after messaging the channel ,you can store the return id (the id of the message) in the same class array
myTrades[x].reply_message_id=last_message_id;
then when stop loss is hit for example you could :
if(myTrades[x].reply_messge_id!=-1) > quote and message
*/intOnInit()
{
last_message_id=-1;
telegram_running=false;
StartTelegramService();
//finding your channels idstring ids="-100"+channel_private_id_string;
private_channel_string_id=ids;
long idl=(long)StringToInteger(ids);
private_channel_prepost_id=(long)StringToInteger(channel_private_id_string);
private_channel_post_id=idl;
if(idl>=0)
{
Alert("Invalid Private Channel ID");
ExpertRemove();
telegram_running=false;
}
//test message and its quote /*
string txt="This will be quoted";
last_message_id=-1;
int res=bot.SendMessageGetID(false,0,private_channel_post_id,txt,NULL,false,false,last_message_id);
//if it was sent
if(last_message_id!=-1)
{
Sleep(1000);
//reply to it !
txt="Reply test!";
long reply_id=-1;
bot.SendMessageGetID(true,last_message_id,private_channel_post_id,txt,NULL,false,false,reply_id);
}
*/string name_for_screenshot="Screenie.bmp";
bool capture=ChartScreenShot(ChartID(),name_for_screenshot,100,100,ALIGN_RIGHT);
ResourceCreate("SeV",name_for_screenshot);
FileDelete(name_for_screenshot);
ResourceSave("Sev",name_for_screenshot);
ResourceFree("Sev");
//if screenshot taken
last_message_id=-1;
if(capture)
{
string get_photo_id_string="";
string caption="Caption Of Screenshot";
bot.SendPhotoGetID(false,-1,get_photo_id_string,private_channel_post_id,name_for_screenshot,caption,false,1000,last_message_id);
if(last_message_id!=-1)
{
Alert("ID for reply : "+IntegerToString(last_message_id));
//delaySleep(1000);
//reply to photo ! string txt="Reply to photo !";
bot.SendMessageGetID(true,last_message_id,private_channel_post_id,txt,NULL,false,false,last_message_id);
}
}
//if screenshot taken ends here return(INIT_SUCCEEDED);
}
//TELEGRAM STUFF class CMyBot: public CCustomBot
{
private:
int m_radio_index;
bool m_lock_state;
bool m_mute_state;
public:
//find chat id of private channel long FindChannelChatId(string c_name,long normal_id,long post_id)
{
long returnio=-1;
int total_chats=bot.ChatsTotal();
for(int c=0;c<total_chats;c++)
{
CCustomChat chat=m_chats.GetNodeAtIndex(c);
}
return(returnio);
}
//find chat id of private channel ends here
};
//---//---
CMyBot bot;
int getme_result;
//user structure - for signals long telegram_chat_ids[];
int telegram_chats_total=0;
int telegram_chats_size=0;
int telegram_chats_step=10;
bool telegram_running=false,must_hide_keyboard=false;
//start telegram service and get id's void StartTelegramService()
{
telegram_running=true;
must_hide_keyboard=false;
//--- set token
bot.Token(InpToken);
//--- check token
getme_result=bot.GetMe();
if(getme_result!=0) telegram_running=false;
//if(telegram_running) Alert("Bot Name : "+bot.Name);if(telegram_running==false)
{
Alert("Could not start telegram service!");
ExpertRemove();
}
}
//start telegram service and get id's ends here //TELEGRAM STUFF ENDS HERE
There was nothing bounded to the first boolean above, so I changed it to true and added this code to SendPhotoGetID in TelegramLmqh to reply with photos :
There is no error when I send messages to telegram but this doesnt work.
I'm guessing it has something to do with:
int res=WebRequest("POST",url,headers,_timeout,data,result,result_headers);
as the params variable isn't defined in it.
I tried to add it but WebRequest seems to have a defined parameters count. So I went with PostRequest like with SendMessageGetID but still no luck there...
It returns "Bad request" if you print the "out" variable in thefunction?
I dont think you can reply to a photo with a photo - but i'll mod it ,see what i mean with code fit ? i forgot to place that functionality :D -
---- edits :
First go to the SendMessageGetID and follow the params -where they are sent , we see a PostRequest function.Go in there ...
In the PostRequest function ,can see the params are sent in the data as a char array ,so now go to SendPhotoGetID and look for where these char arrays are ...
There is a uchar array data[] thats where the photo data is sent so we utilize this , now we need to find if we plug our "replying_id" above or below the data (probably above)...
We see a chat id is sent in the top section of the data ,so we plug the replying id there and add a line as well ...
Hmm ,doesnt look very reply-ish : (maybe cause im sending the same photo)
#property strict#include <Telegram\TelegramL.mqh>
inputstring channel_name="";//PRIVATE CHANNEL NAME (string)inputstring channel_private_id_string="";//PRIVATE CHANNEL ID (string)string InpToken="";//telegram input token// to get private channel id//Log into Telegram via web: https://web.telegram.org//Find your channel and copy the URL. //You should have something like this: https://web.telegram.org/#/im?p=c**NUMBER**_number//The numbers between "c" and "_" are the ID of your private channel.//Now tell your bot to send the messages to chat_id=-100NUMBER//mql code : /*
id in webtelegram c1334309342_1978467370643286368 >
1334309342 >
-1001334309342 >
string ids="-1001334309342";
long idl=(long)StringToInteger(ids);
bot.SendMessage(idl,messi,NULL,false,false);
*/string private_channel_string_id="";
long private_channel_post_id=0,private_channel_prepost_id=0;
//id of last message for replies long last_message_id=-1;
/*
you can implement a solution where in your trades monitoring class
you maintain the message id that was produced after the trade was posted in the telegram channel
for example ,you open a buy order ,you get its ticket ,you store it in your class array with your trades
myTrades[x].ticket=ticket;
then after messaging the channel ,you can store the return id (the id of the message) in the same class array
myTrades[x].reply_message_id=last_message_id;
then when stop loss is hit for example you could :
if(myTrades[x].reply_messge_id!=-1) > quote and message
*/intOnInit()
{
last_message_id=-1;
telegram_running=false;
StartTelegramService();
//finding your channels idstring ids="-100"+channel_private_id_string;
private_channel_string_id=ids;
long idl=(long)StringToInteger(ids);
private_channel_prepost_id=(long)StringToInteger(channel_private_id_string);
private_channel_post_id=idl;
if(idl>=0)
{
Alert("Invalid Private Channel ID");
ExpertRemove();
telegram_running=false;
}
//test message and its quote /*
string txt="This will be quoted";
last_message_id=-1;
int res=bot.SendMessageGetID(false,0,private_channel_post_id,txt,NULL,false,false,last_message_id);
//if it was sent
if(last_message_id!=-1)
{
Sleep(1000);
//reply to it !
txt="Reply test!";
long reply_id=-1;
bot.SendMessageGetID(true,last_message_id,private_channel_post_id,txt,NULL,false,false,reply_id);
}
*/string name_for_screenshot="Screenie.bmp";
bool capture=ChartScreenShot(ChartID(),name_for_screenshot,100,100,ALIGN_RIGHT);
ResourceCreate("SeV",name_for_screenshot);
FileDelete(name_for_screenshot);
ResourceSave("Sev",name_for_screenshot);
ResourceFree("Sev");
//if screenshot taken
last_message_id=-1;
if(capture)
{
string get_photo_id_string="";
string caption="Caption Of Screenshot";
bot.SendPhotoGetID(false,-1,get_photo_id_string,private_channel_post_id,name_for_screenshot,caption,false,1000,last_message_id);
if(last_message_id!=-1)
{
Alert("ID for reply : "+IntegerToString(last_message_id));
//delaySleep(1000);
//reply to photo ! /* reply with text
string txt="Reply to photo !";
bot.SendMessageGetID(true,last_message_id,private_channel_post_id,txt,NULL,false,false,last_message_id);
*///reply with same photo
bot.SendPhotoGetID(true,last_message_id,get_photo_id_string,private_channel_post_id,name_for_screenshot,"",false,1000,last_message_id);
}
}
//if screenshot taken ends here return(INIT_SUCCEEDED);
}
//TELEGRAM STUFF class CMyBot: public CCustomBot
{
private:
int m_radio_index;
bool m_lock_state;
bool m_mute_state;
public:
//find chat id of private channel long FindChannelChatId(string c_name,long normal_id,long post_id)
{
long returnio=-1;
int total_chats=bot.ChatsTotal();
for(int c=0;c<total_chats;c++)
{
CCustomChat chat=m_chats.GetNodeAtIndex(c);
}
return(returnio);
}
//find chat id of private channel ends here
};
//---//---
CMyBot bot;
int getme_result;
//user structure - for signals long telegram_chat_ids[];
int telegram_chats_total=0;
int telegram_chats_size=0;
int telegram_chats_step=10;
bool telegram_running=false,must_hide_keyboard=false;
//start telegram service and get id's void StartTelegramService()
{
telegram_running=true;
must_hide_keyboard=false;
//--- set token
bot.Token(InpToken);
//--- check token
getme_result=bot.GetMe();
if(getme_result!=0) telegram_running=false;
//if(telegram_running) Alert("Bot Name : "+bot.Name);if(telegram_running==false)
{
Alert("Could not start telegram service!");
ExpertRemove();
}
}
//start telegram service and get id's ends here //TELEGRAM STUFF ENDS HERE
This is because this isn't a reply, and yes I thought exactly the same thing about the photo, but I tried with a different one and it doesnt change anything.
This is because this isn't a reply, and yes I thought exactly the same thing about the photo, but I tried with a different one and it doesnt change anything.
edit:
Alright I found what was the error
I removed the "=" ->
Wow excellent :) . nice catch .
(and also added ArrayAdd(data,"--"+hash+"\r\n"); after the if replying to message)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Oh , nice .
You modified SendPhoto or SendMessageGetID ?
SendPhoto, but there is multiple SendPhoto function in the file, maybe I picked the wrong one?
SendPhoto, but there is multiple SendPhoto function in the file, maybe I picked the wrong one?
No it was okay .
No it was okay .
You trully are amazing!
I learned many thing thanks to you, can I buy you a coffee? Its not much but its the least I can do given how much you gave me this past few days.
Please send me your paypal in private Lorentzos :)
You trully are amazing!
I learned many thing thanks to you, can I buy you a coffee? Its not much but its the least I can do given how much you gave me this past few days.
Please send me your paypal in private Lorentzos :)
No problem , i try to code everyday to stay "code fit". We might have that coffee someday ,thats all . :)
There was nothing bounded to the first boolean above, so I changed it to true and added this code to SendPhotoGetID in TelegramLmqh to reply with photos :
There is no error when I send messages to telegram but this doesnt work.
I'm guessing it has something to do with:
as the params variable isn't defined in it.
I tried to add it but WebRequest seems to have a defined parameters count. So I went with PostRequest like with SendMessageGetID but still no luck there...
No problem , i try to code everyday to stay "code fit". We might have that coffee someday ,thats all . :)
Alright ahah.
out is initialised but not defined, is it a variable that will receive its value by telegram in this case?
in any case, no error when I print it.
We can reply to a photo with a photo without problem in telegram so why not?
edit:
here I have a bad request ("no photo in the request")
It returns "Bad request" if you print the "out" variable in the function ?
I dont think you can reply to a photo with a photo - but i'll mod it ,see what i mean with code fit ? i forgot to place that functionality :D -
---- edits :
Hmm ,doesnt look very reply-ish : (maybe cause im sending the same photo)
This is because this isn't a reply, and yes I thought exactly the same thing about the photo, but I tried with a different one and it doesnt change anything.
edit:
Alright I found what was the error
I removed the "=" ->
form-data; name=\"reply_to_message_id=This is because this isn't a reply, and yes I thought exactly the same thing about the photo, but I tried with a different one and it doesnt change anything.
edit:
Alright I found what was the error
I removed the "=" ->
Wow excellent :) . nice catch .
(and also added ArrayAdd(data,"--"+hash+"\r\n"); after the if replying to message)