shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

Can bot directly send image with command ? #87

Open chopind16 opened 2 years ago

chopind16 commented 2 years ago

`#include "CTBot.h"

CTBot myBot; String ssid = "idih"; String pass = "ngapo nanyo aku."; String token = "1880656074:AAHurevCe1Kw9UMeokrvs-2eDeAVdd_tMGY"; const int id = 780422297; String foto = "https://www.arduino.cc/en/uploads/Trademark/ArduinoCommunityLogo.png";

void setup() { Serial.begin(9600); Serial.println("Starting TelegramBot..."); myBot.wifiConnect(ssid, pass); myBot.setTelegramToken(token);

if (myBot.testConnection()) { Serial.println("Koneksi Bagus"); } else { Serial.println("Koneksi Jelek"); }

}

void loop() { TBMessage msg; if (myBot.getNewMessage(msg)){ if (msg.text.equalsIgnoreCase("/image")) {
myBot.sendMessage(msg.sender.id, foto); } } } `

as you can see i make command /image, so my bot can send me an image every time i type my command. but my bot still send me link of image first. can someone help me how to make my bot directly send image from link without having to send a link again to me

shurillu commented 2 years ago

Hello chopind16, actually the only way to send an image is to use the library version v3.0.0 (see the v3.0.0 branch) and calling the sendImage() method. You can send only binary data stored locally in memory or in a file (for example in a SD). I have to add some examples, it's a work in progress work. I'm wondering if I will add this functionality, maybe in the future.

Cheers,

Stefano