This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cotestatnt/dev
Dev
- Loading branch information
Showing
6 changed files
with
94 additions
and
21 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
/* | ||
Name: echoBot.ino | ||
Name: echoBot.ino | ||
Created: 20/06/2020 | ||
Author: Tolentino Cotesta <[email protected]> | ||
Description: a simple example that check for incoming messages | ||
and reply the sender with the received message | ||
and reply the sender with the received message. | ||
The message will be forwarded also in a public channel | ||
and to a specific userid. | ||
*/ | ||
#include <Arduino.h> | ||
#include "AsyncTelegram.h" | ||
AsyncTelegram myBot; | ||
|
||
const char* ssid = "XXXXXXXX"; // REPLACE mySSID WITH YOUR WIFI SSID | ||
const char* pass = "XXXXXXXX"; // REPLACE myPassword YOUR WIFI PASSWORD, IF ANY | ||
const char* ssid = "XXXXXXXX"; // REPLACE mySSID WITH YOUR WIFI SSID | ||
const char* pass = "XXXXXXXX"; // REPLACE myPassword YOUR WIFI PASSWORD, IF ANY | ||
const char* token = "XXXXXXXXXXXXXXXXXXXX"; // REPLACE myToken WITH YOUR TELEGRAM BOT TOKEN | ||
const uint8_t LED = 4; | ||
|
||
// Name of public channel (your bot must be in admin group) | ||
const char* channel = "@tolentino_cotesta"; | ||
|
||
void setup() { | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
// initialize the Serial | ||
Serial.begin(115200); | ||
Serial.println("Starting TelegramBot..."); | ||
|
@@ -31,13 +35,17 @@ void setup() { | |
} | ||
|
||
// Set the Telegram bot properies | ||
myBot.setUpdateTime(2000); | ||
myBot.setTelegramToken(token); | ||
|
||
// Check if all things are ok | ||
Serial.print("\nTest Telegram connection... "); | ||
myBot.begin() ? Serial.println("OK") : Serial.println("NOK"); | ||
|
||
//if( myBot.updateFingerPrint()) | ||
// Serial.println("Telegram fingerprint updated"); | ||
myBot.setUpdateTime(2000); | ||
myBot.setTelegramToken(token); | ||
|
||
// Check if all things are ok | ||
Serial.print("\nTest Telegram connection... "); | ||
myBot.begin() ? Serial.println("OK") : Serial.println("NOK"); | ||
|
||
Serial.print("Bot name: @"); | ||
Serial.println(myBot.userName); | ||
} | ||
|
||
void loop() { | ||
|
@@ -53,6 +61,24 @@ void loop() { | |
|
||
// if there is an incoming message... | ||
if (myBot.getNewMessage(msg)){ | ||
myBot.sendMessage(msg, msg.text); | ||
|
||
// Send a message to your public channel | ||
String message ; | ||
message += "Message from @"; | ||
message += myBot.userName; | ||
message += ":\n"; | ||
message += msg.text; | ||
Serial.println(message); | ||
myBot.sendToChannel(channel, message, true); | ||
|
||
// Send a message to specific user who has started your bot | ||
// Target user can find it's own userid with the bot @JsonDumpBot | ||
// https://t.me/JsonDumpBot | ||
int32_t userid = 1234567890; | ||
myBot.sendToUser(userid, msg.text); | ||
|
||
// echo the received message | ||
myBot.sendMessage(msg, msg.text); | ||
} | ||
} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=AsyncTelegram | ||
version=1.0.4 | ||
version=1.0.5 | ||
author=Tolentino Cotesta <[email protected]> | ||
maintainer=Tolentino Cotesta <[email protected]> | ||
sentence=Simple Arduino Telegram BOT library for ESP8266 and ESP32 | ||
|
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
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