#include "CTBot.h";
CTBot mybot;
String ssid = "Wokwi-GUEST";
String pass = "";
String token = "5540487735:AAHYC7Y-8YjxmWQz8ch91n_sq9d0lTuUl-A";
const int id = 1530827924;
int led = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led, OUTPUT);
Serial.println("Memulai telegram bot");
mybot.wifiConnect(ssid, pass);
mybot.setTelegramToken(token);
if(mybot.testConnection())
Serial.println("koneksi berhasil");
else
Serial.println("Koneksi Gagal ");
}
void loop() {
// put your main code here, to run repeatedly:
TBMessage msg;
if(mybot.getNewMessage(msg)){
Serial.println("Pesan masuk : "+msg.text);
String pesan = msg.text;
if(pesan=="on"){
digitalWrite(led, LOW); //led nodemcu menyala
mybot.sendMessage(id, "Led Menyala");
}
else if (pesan=="off"){
digitalWrite(led, HIGH); //led nodemcu mati
mybot.sendMessage(id, "Led Mati");
}
}
}