#include "CTBot.h"
CTBot myBot;
String ssid = "Wokwi-GUEST";
String pass = "";
String token = "5606046834:AAEVBcXTjmo6rXgCoQA67YbHsNO-6WE2dHY";
int buzzer = 4;
void setup() {
Serial.begin(115200);
Serial.println("Starting TelegramBot...");
if (myBot.wifiConnect(ssid, pass))
Serial.println("\nWifi OK");
else
Serial.println("\nWifi Not OK");
myBot.setTelegramToken(token);
if (myBot.testConnection())
Serial.println("\nConnection OK");
else
Serial.println("\nBad Connection");
}
void loop() {
TBMessage msg;
if (myBot.getNewMessage(msg)) {
if (msg.text.equalsIgnoreCase("ON")) {
tone(buzzer, 1000);
myBot.sendMessage(msg.sender.id, "Tone ON");
}
else if (msg.text.equalsIgnoreCase("OFF")) {
noTone(buzzer);
myBot.sendMessage(msg.sender.id, "Tone OFF");
}
else {
String reply;
reply = (String)"Welcome " + msg.sender.username + (String)". Try Type ON or OFF.";
myBot.sendMessage(msg.sender.id, reply); }
}
delay(500);
}