using <UniversalTelegramBot.h>how to sent different message when distance change

eg:

void telegramButton1Pressed() {
Serial.println("Telegram Button-1 Pressed");
int echo = digitalRead(ECHOPIN );
if(dist <10 && SendingMessage)
{
telegramButton1PressedFlag = true;
return;
}

void sendTelegramMessage1() {
String message = "Dustbin is full,needed to clean up!";
if(bot.sendMessage(CHAT_ID, message, "Markdown")){
Serial.println("TELEGRAM Message 1 Successfully sent");
}
telegramButton1PressedFlag = false;
}

void telegramButton2Pressed() {
Serial.println("Telegram Button-2 Pressed");
int echo = digitalRead(ECHOPIN );
if(dist >10 )
{
telegramButton2PressedFlag = true;
}
return;
}

void sendTelegramMessage2() {
String message2 = "Dustbin is been clean up!";
if(bot.sendMessage(CHAT_ID, message2, "Markdown")){
Serial.println("TELEGRAM Message 2 Successfully sent");
}
telegramButton2PressedFlag = false;
}

it will only appearing first message when it detected the distance <10 it will not shown the message 2 when distance appeared >10

#include <UniversalTelegramBot.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <SoftwareSerial.h> // Software Serial library
#include "NewPing.h"

#define ECHOPIN D2// Pin to receive echo pulse
#define TRIGPIN D1// Pin to send trigger pulse
#define MAX_DISTANCE 400 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
boolean SendingMessage = true;
boolean SendingMessage2 = true;
NewPing sonar(TRIGPIN, ECHOPIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
long duration; // declare duration as long. Long can store a bigger number than int.
int dist = 0; // declare dist as integer

//------- WiFi Settings -------
char ssid[] = ""; // your network SSID (name)
char password[] = ""; // your network key

// ------- Telegram config --------
#define BOT_TOKEN "" // your Bot Token (Get from Botfather)
#define CHAT_ID "" // Chat ID of where you want the message to go (You can use MyIdBot to get the chat ID)

// SSL client needed for both libraries
WiFiClientSecure client;

UniversalTelegramBot bot(BOT_TOKEN, client);

String ipAddress = "";

volatile bool telegramButton1PressedFlag = false;
volatile bool telegramButton2PressedFlag = false;

void setup() {
Serial.begin(9600);
pinMode(TRIGPIN, OUTPUT); // Sets the trigPin as an Output
pinMode(ECHOPIN, INPUT);// Sets the echoPin as an Input
digitalWrite(ECHOPIN, HIGH);

// Set WiFi to station mode and disconnect from an AP if it was Previously
// connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);

// Attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
IPAddress ip = WiFi.localIP();
Serial.println(ip);

ipAddress = ip.toString();
}
void telegramButton1Pressed() {
Serial.println("Telegram Button-1 Pressed");
int echo = digitalRead(ECHOPIN );
if(dist <10 && SendingMessage)
{
telegramButton1PressedFlag = true;
SendingMessage = false;
telegramButton2PressedFlag = true;
}if (dist >10 && SendingMessage2)
SendingMessage2 = true;
return;
}

void sendTelegramMessage1() {
String message = "Dustbin is full,needed to clean up!";
if(bot.sendMessage(CHAT_ID, message, "Markdown")){
Serial.println("TELEGRAM Message 1 Successfully sent");
}
telegramButton1PressedFlag = false;
}

void telegramButton2Pressed() {
Serial.println("Telegram Button-2 Pressed");
int echo = digitalRead(ECHOPIN );
if(dist >10 && SendingMessage2)
{
telegramButton2PressedFlag = true;
SendingMessage2 = false;
}
return;
}

void sendTelegramMessage2() {
String message2 = "Dustbin is been clean up!";
if(bot.sendMessage(CHAT_ID, message2, "Markdown")){
Serial.println("TELEGRAM Message 2 Successfully sent");
}
telegramButton2PressedFlag = false;
}

void loop() {
dist = sonar.ping_cm();
Serial.print(dist);
Serial.println(" cm");
delay(100);

if (dist <10 && SendingMessage) {
Serial.println("sent notifcation1 to Telegram");
sendTelegramMessage1();
SendingMessage = false;

if(dist >10 && SendingMessage2){
Serial.println("sent notifcation2 to Telegram");
sendTelegramMessage2();
SendingMessage2 = false;

}
}
}

Delta_G:

Delta_G:
Use code tags when you do.

What?

Delta_G:
please format your code AND USE CODE TAGS if you post anything further.

If you ignore this request then you will not get anymore replies.

If you don't know what I mean by code tags, then read the "How to use this forum" thread which you should have read before you got started.

@Mrtian2, this is actually quite important. Code gets mangles when you post it the way you did. Follow the link in the above quote abd read the stuff there.

``sorry beginner to coding .I though ultrasonic is a digital Pin because i need to reading the value of distance so that the message will been post .

Delta_G:
There was more code posted that got removed after I posted. It made sense when I posted it.

My "What?" was rhetorical. OP still hasn't posted in code tags (although it looks as if an attempt has been made), and has not used Autoformat in the IDE. I wonder if the spate of poorly formatted code is due to Arduino's newfangled online editor lacking that capability. Couple this with the 5 minute posting rule for newbs, and we get slow to react, and frustrated newbs.

Both those problems could be addressed by an active administration, a lot of communication issues here could be alleviated.

Its works only that when it change to distance more than 10 it will not post second message .