Created
May 16, 2022 22:24
-
-
Save chepecarlos/f8f0b74c43179f666162e3dca13d430b to your computer and use it in GitHub Desktop.
Demo de Telegram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T> inline Print &operator <<(Print &obj, T arg) { | |
obj.print(arg); | |
return obj; | |
} | |
#include "CTBot.h" | |
CTBot miBot; | |
#include "token.h" | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("Iniciando Sistema de Telegram"); | |
miBot.wifiConnect(ssid1, password1); | |
miBot.setTelegramToken(token); | |
if (miBot.testConnection()) | |
Serial.println("\n Conectado"); | |
else | |
Serial.println("\n Problemas Auxilio"); | |
} | |
void loop() { | |
TBMessage msg; | |
if (CTBotMessageText == miBot.getNewMessage(msg)) { | |
Serial << "Mensaje " << msg.sender.firstName << " - " << msg.text << "\n"; | |
if (msg.text.equals("encender")) { | |
Serial.println("Encender Motor"); | |
miBot.sendMessage(msg.sender.id, "Encendiendo Motor"); | |
// Codigo de motor endender | |
} | |
else if (msg.text.equals("apagar")) { | |
Serial.println("Aoagar Motor"); | |
miBot.sendMessage(msg.sender.id, "Apagar Motor"); | |
// Codigo de motor apagado | |
} | |
else { | |
Serial.println("no entiendo mensaje"); | |
miBot.sendMessage(msg.sender.id, "No entiendo manda(encender o apagar"); | |
} | |
// myBot.sendMessage(msg.sender.id, msg.text); | |
} | |
delay(500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const char* ssid1 = "xxx"; | |
const char* password1 = "xxx"; | |
const String token = "xxx"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment