AsyncTelegram with esp32

Hi, Everyone!
I am trying to use AsyncTelegram with esp32 to send messages to a channel. But the message is sent one time only . The main loop has this code:

void loop()
.....
if ((millis() - temp_start) > 30000)//every 30 sec
{
temp_start = millis();
tm* _tm;
time_t utcTime = time(NULL);
_tm = localtime(&utcTime);

    String str;
    char buf[100];
    strftime(buf, sizeof(buf), "This is esp32 message at:  %A, %B %d %Y %H:%M:%S", _tm);
    str = buf;
    Serial.println(str); //see it every 30 sec
    myBot.sendToChannel(channel_id, str, true);//see it only first time in my channel and in serial log
}
....

What could be the problem?

unsigned long markTime;
unsigned long currentTime;
bool flag = false;

void setup() 
{
  Serial.begin(19200);
  markTime = millis();
}

void loop() 
{
  currentTime = millis();
  if (currentTime - markTime > halfmin)
  {
    flag = false;
    markTime = millis();
  }
  if(!flag)
  {
    Serial.println("X");
    flag = true;
  }
}

OK.

if(!flag)
  {
    Serial.println("X");
    flag = true;
    **myBot.sendToChannel(....) //occurs one time only**
  }

The problem is not "execute every 30 seconds", but that the message only goes out once, even though the code is executed every 30 seconds

The issue may be elsewhere in your code. Code snippets are poo! Post all your code.

Might provide some info.

You have to poll the Telegram server even if you don't need to handle received messages otherwise connection will be closed after a while from server and the bot can't send messages anymore.

Try with this:

void loop() 
{
  TBMessage msg;
  myBot.getNewMessage(msg) ;
    
  static uint32_t temp_start;
  if ((millis() - temp_start) > 30000)//every 30 sec
  {
    temp_start = millis();
    tm* _tm;
    time_t utcTime = time(NULL);
    _tm = localtime(&utcTime);

    char buf[100];
    strftime(buf, sizeof(buf), "This is esp32 message at:  %A, %B %d %Y %H:%M:%S", _tm);
    Serial.println(buf);
    myBot.sendToChannel(channel_id, buf, true);
  }
}

P.S.
I hope you mean AsyncTelegram2, because AsyncTelegram is no longer mantained