Skip to content

Commit a7b054b

Browse files
committed
Set from_name as Guest if it's empty.
1 parent bbe4189 commit a7b054b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

examples/ESP8266/CustomKeyboard/InlineKeyboardMarkup/InlineKeyboardMarkup.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ void handleNewMessages(int numNewMessages) {
2828
for (int i=0; i<numNewMessages; i++) {
2929
String chat_id = String(bot.messages[i].chat_id);
3030
String text = bot.messages[i].text;
31+
3132
String from_name = bot.messages[i].from_name;
33+
if (from_name == "") from_name = "Guest";
3234

3335
if (text == "/options") {
3436
String keyboardJson = "[[\{ \"text\" : \"Go to Google\", \"url\" : \"https://www.google.com\" \} ]]";

examples/ESP8266/CustomKeyboard/ReplyKeyboardMarkup/ReplyKeyboardMarkup.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ void handleNewMessages(int numNewMessages) {
3131
for (int i=0; i<numNewMessages; i++) {
3232
String chat_id = String(bot.messages[i].chat_id);
3333
String text = bot.messages[i].text;
34+
3435
String from_name = bot.messages[i].from_name;
36+
if (from_name == "") from_name = "Guest";
3537

3638
if (text == "/ledon") {
3739
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)

examples/ESP8266/FlashledBot/FlashledBot.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ void handleNewMessages(int numNewMessages) {
3232
for(int i=0; i<numNewMessages; i++) {
3333
String chat_id = String(bot.messages[i].chat_id);
3434
String text = bot.messages[i].text;
35+
36+
String from_name = bot.messages[i].from_name;
37+
if (from_name == "") from_name = "Guest";
38+
3539
if (text == "/ledon") {
3640
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
3741
ledStatus = 1;
@@ -50,9 +54,6 @@ void handleNewMessages(int numNewMessages) {
5054
}
5155
}
5256
if (text == "/start") {
53-
String from_name = bot.messages[i].from_name;
54-
if (from_name == "") from_name = "Anonymous";
55-
5657
String welcome = "Welcome, " + from_name + ", from FlashLedBot, your personal Bot on ESP8266\n";
5758
welcome = welcome + "/ledon : to switch the Led ON\n";
5859
welcome = welcome + "/ledoff : to switch the Led OFF\n";

0 commit comments

Comments
 (0)