Skip to content

Commit 0a7322d

Browse files
authored
Merge pull request #1 from witnessmenow/master
From main to my fork
2 parents b954cad + 047f74f commit 0a7322d

File tree

11 files changed

+79
-67
lines changed

11 files changed

+79
-67
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,16 @@ Gets any pending messages from Telegram and stores them in bot.messages . Offset
7676

7777
Here are listed some examples to help you to build your own Bot:
7878

79+
- BulkMessages : sends messages to multiple subscribers (ESP8266 only).
80+
7981
- EchoBot : replies echoing your messages.
8082

8183
- FlashLedBot : Reacts to your command switching ON/OFF a GPIO.
8284

8385
- CustomKeyboard : Same as FlashLedBot but also uses a replyKeyboard
8486

87+
- UsingWifiManager : Same as FlashLedBot but also uses WiFiManager library to configure WiFi (ESP8266 only).
88+
8589

8690

8791
## License

examples/101/CustomKeyboard/CustomKeyboard.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ char password[] = "yyyyyyyy"; // your network key
1919
const int ledPin = 13;
2020

2121
// Initialize Telegram BOT
22-
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get off Botfather)
22+
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)
2323

2424
WiFiSSLClient client;
2525
UniversalTelegramBot bot(BOTtoken, client);
@@ -57,7 +57,7 @@ void handleNewMessages(int numNewMessages) {
5757
}
5858

5959
if (text == "/start") {
60-
String welcome = "Wellcome from FlashLedBot, your personal Bot on ESP8266 board \n";
60+
String welcome = "Welcome from FlashLedBot, your personal Bot on Arduino 101\n";
6161
welcome = welcome + "/ledon : to switch the Led ON \n";
6262
welcome = welcome + "/ledoff : to switch the Led OFF \n";
6363
welcome = welcome + "/status : Returns current status of LED \n";
@@ -87,7 +87,7 @@ void setup() {
8787

8888
pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
8989
delay(10);
90-
digitalWrite(ledPin, HIGH); //initilase pin as off
90+
digitalWrite(ledPin, HIGH); // initialize pin as off
9191

9292
}
9393

@@ -96,11 +96,11 @@ void setup() {
9696
void loop() {
9797

9898
if (millis() > Bot_lasttime + Bot_mtbs) {
99-
int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
99+
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
100100
while(numNewMessages) {
101101
Serial.println("got response");
102102
handleNewMessages(numNewMessages);
103-
numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
103+
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
104104
}
105105
Bot_lasttime = millis();
106106
}

examples/101/EchoBot/EchoBot.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ char password[] = "yyyyyyyyy"; // your network key
1919

2020

2121
// Initialize Telegram BOT
22-
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get off Botfather)
22+
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)
2323

2424
WiFiSSLClient client;
2525
UniversalTelegramBot bot(BOTtoken, client);
@@ -53,13 +53,13 @@ void setup() {
5353
void loop() {
5454

5555
if (millis() > Bot_lasttime + Bot_mtbs) {
56-
int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
56+
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
5757
while(numNewMessages) {
5858
Serial.println("got response");
5959
for(int i=0; i<numNewMessages; i++) {
6060
bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].text, "");
6161
}
62-
numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
62+
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
6363
}
6464
Bot_lasttime = millis();
6565
}

examples/101/FlashledBot/FlashledBot.ino

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ char password[] = "yyyyyyyy"; // your network key
2020
const int ledPin = 13;
2121

2222
// Initialize Telegram BOT
23-
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get off Botfather)
23+
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)
2424

2525
WiFiSSLClient client;
2626
UniversalTelegramBot bot(BOTtoken, client);s
@@ -54,7 +54,10 @@ void handleNewMessages(int numNewMessages) {
5454
}
5555
}
5656
if (text == "/start") {
57-
String welcome = "Wellcome from FlashLedBot, your personal Bot on ESP8266 board \n";
57+
String from_name = message.from_name;
58+
if (from_name == "") from_name = "Anonymous";
59+
60+
String welcome = "Welcome, " + from_name + ", from FlashLedBot, your personal Bot on Arduino 101\n";
5861
welcome = welcome + "/ledon : to switch the Led ON \n";
5962
welcome = welcome + "/ledoff : to switch the Led OFF \n";
6063
welcome = welcome + "/status : Returns current status of LED \n";
@@ -84,18 +87,18 @@ void setup() {
8487

8588
pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
8689
delay(10);
87-
digitalWrite(ledPin, LOW); //initilase pin as off
90+
digitalWrite(ledPin, LOW); //initialize pin as off
8891

8992
}
9093

9194
void loop() {
9295

9396
if (millis() > Bot_lasttime + Bot_mtbs) {
94-
int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
97+
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
9598
while(numNewMessages) {
9699
Serial.println("got response");
97100
handleNewMessages(numNewMessages);
98-
numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
101+
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
99102
}
100103
Bot_lasttime = millis();
101104
}

examples/ESP8266/BulkMessages/BulkMessages.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ char ssid[] = "xxxxxxx"; // your network SSID (name)
1515
char password[] = "yyyyyyyy"; // your network key
1616

1717
// Initialize Telegram BOT
18-
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get off Botfather)
18+
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)
1919

2020
WiFiClientSecure client;
2121
UniversalTelegramBot bot(BOTtoken, client);
@@ -205,12 +205,12 @@ void setup() {
205205

206206
void loop() {
207207
if (millis() > Bot_lasttime + Bot_mtbs) {
208-
int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
208+
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
209209

210210
while(numNewMessages) {
211211
Serial.println("got response");
212212
handleNewMessages(numNewMessages);
213-
numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
213+
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
214214
}
215215

216216
Bot_lasttime = millis();

examples/ESP8266/CustomKeyboard/CustomKeyboard.ino

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ char password[] = "yyyyyyyy"; // your network key
1919
const int ledPin = 13;
2020

2121
// Initialize Telegram BOT
22-
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get off Botfather)
22+
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)
2323

2424
WiFiClientSecure client;
2525
UniversalTelegramBot bot(BOTtoken, client);
@@ -57,11 +57,11 @@ void handleNewMessages(int numNewMessages) {
5757
}
5858

5959
if (text == "/start") {
60-
String welcome = "Wellcome from FlashLedBot, your personal Bot on ESP8266 board \n";
61-
welcome = welcome + "/ledon : to switch the Led ON \n";
62-
welcome = welcome + "/ledoff : to switch the Led OFF \n";
63-
welcome = welcome + "/status : Returns current status of LED \n";
64-
welcome = welcome + "/options : returns the custom keyboard \n";
60+
String welcome = "Welcome from FlashLedBot, your personal Bot on ESP8266\n";
61+
welcome = welcome + "/ledon : to switch the Led ON\n";
62+
welcome = welcome + "/ledoff : to switch the Led OFF\n";
63+
welcome = welcome + "/status : Returns current status of LED\n";
64+
welcome = welcome + "/options : returns the custom keyboard\n";
6565
bot.sendMessage(chat_id, welcome, "Markdown");
6666
}
6767
}
@@ -92,7 +92,7 @@ void setup() {
9292

9393
pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
9494
delay(10);
95-
digitalWrite(ledPin, HIGH); //initilase pin as off
95+
digitalWrite(ledPin, HIGH); // initialize pin as off
9696

9797
}
9898

@@ -101,11 +101,11 @@ void setup() {
101101
void loop() {
102102

103103
if (millis() > Bot_lasttime + Bot_mtbs) {
104-
int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
104+
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
105105
while(numNewMessages) {
106106
Serial.println("got response");
107107
handleNewMessages(numNewMessages);
108-
numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
108+
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
109109
}
110110
Bot_lasttime = millis();
111111
}

examples/ESP8266/EchoBot/EchoBot.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ char password[] = "yyyyyyyyy"; // your network key
1818

1919

2020
// Initialize Telegram BOT
21-
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get off Botfather)
21+
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)
2222

2323
WiFiClientSecure client;
2424
UniversalTelegramBot bot(BOTtoken, client);
@@ -57,13 +57,13 @@ void setup() {
5757
void loop() {
5858

5959
if (millis() > Bot_lasttime + Bot_mtbs) {
60-
int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
60+
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
6161
while(numNewMessages) {
6262
Serial.println("got response");
6363
for(int i=0; i<numNewMessages; i++) {
6464
bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].text, "");
6565
}
66-
numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
66+
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
6767
}
6868
Bot_lasttime = millis();
6969
}

examples/ESP8266/FlashledBot/FlashledBot.ino

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ char password[] = "yyyyyyyy"; // your network key
2020
const int ledPin = 13;
2121

2222
// Initialize Telegram BOT
23-
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get off Botfather)
23+
#define BOTtoken "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // your Bot Token (Get from Botfather)
2424

2525
WiFiClientSecure client;
2626
UniversalTelegramBot bot(BOTtoken, client);
@@ -54,10 +54,13 @@ void handleNewMessages(int numNewMessages) {
5454
}
5555
}
5656
if (text == "/start") {
57-
String welcome = "Wellcome from FlashLedBot, your personal Bot on ESP8266 board \n";
58-
welcome = welcome + "/ledon : to switch the Led ON \n";
59-
welcome = welcome + "/ledoff : to switch the Led OFF \n";
60-
welcome = welcome + "/status : Returns current status of LED \n";
57+
String from_name = message.from_name;
58+
if (from_name == "") from_name = "Anonymous";
59+
60+
String welcome = "Welcome, " + from_name + ", from FlashLedBot, your personal Bot on ESP8266\n";
61+
welcome = welcome + "/ledon : to switch the Led ON\n";
62+
welcome = welcome + "/ledoff : to switch the Led OFF\n";
63+
welcome = welcome + "/status : Returns current status of LED\n";
6164
bot.sendMessage(chat_id, welcome, "Markdown");
6265
}
6366
}
@@ -89,18 +92,18 @@ void setup() {
8992

9093
pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
9194
delay(10);
92-
digitalWrite(ledPin, LOW); //initilase pin as off
95+
digitalWrite(ledPin, LOW); // initialize pin as off
9396

9497
}
9598

9699
void loop() {
97100

98101
if (millis() > Bot_lasttime + Bot_mtbs) {
99-
int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
102+
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
100103
while(numNewMessages) {
101104
Serial.println("got response");
102105
handleNewMessages(numNewMessages);
103-
numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
106+
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
104107
}
105108
Bot_lasttime = millis();
106109
}

examples/ESP8266/UsingWiFiManager/UsingWiFiManager.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ void handleNewMessages(int numNewMessages) {
7878
}
7979
}
8080
if (text == "/start") {
81-
String welcome = "Wellcome from FlashLedBot, your personal Bot on ESP8266 board \n";
82-
welcome = welcome + "/ledon : to switch the Led ON \n";
83-
welcome = welcome + "/ledoff : to switch the Led OFF \n";
84-
welcome = welcome + "/status : Returns current status of LED \n";
81+
String welcome = "Welcome from FlashLedBot, your personal Bot on ESP8266\n";
82+
welcome = welcome + "/ledon : to switch the Led ON\n";
83+
welcome = welcome + "/ledoff : to switch the Led OFF\n";
84+
welcome = welcome + "/status : Returns current status of LED\n";
8585
bot->sendMessage(chat_id, welcome, "Markdown");
8686
}
8787
}
@@ -95,7 +95,7 @@ void setup() {
9595
pinMode(resetConfigPin, INPUT);
9696
pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
9797
delay(10);
98-
digitalWrite(ledPin, LOW); //initilase pin as off
98+
digitalWrite(ledPin, LOW); // initialize pin as off
9999

100100
Serial.println("read bot token");
101101
readBotTokenFromEeprom(0);
@@ -133,11 +133,11 @@ void loop() {
133133
delay(5000);
134134
}
135135
if (millis() > Bot_lasttime + Bot_mtbs) {
136-
int numNewMessages = bot->getUpdates(bot->last_message_recived + 1);
136+
int numNewMessages = bot->getUpdates(bot->last_message_received + 1);
137137
while(numNewMessages) {
138138
Serial.println("got response");
139139
handleNewMessages(numNewMessages);
140-
numNewMessages = bot->getUpdates(bot->last_message_recived + 1);
140+
numNewMessages = bot->getUpdates(bot->last_message_received + 1);
141141
}
142142
Bot_lasttime = millis();
143143
}

0 commit comments

Comments
 (0)