I need help writing and modifying the code

I use these components:
ESP32-WROVER-E
2MP-OV2640 Camera Module
Adafruit I2S MEMS Microphone
IR Remote receiver
And use this code

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <HardwareSerial.h>
#include <UniversalTelegramBot.h>
#include <DFRobot_VoiceRecorder.h>
#include <Adafruit_Sensor.h>
#include <Arducam_Mega.h>
#include <IRremote.h>


const char* ssid = "**********";
const char* password = "************";

#define BOT_TOKEN "*****************"
#define CHAT_ID "***********"

#define CAM_SCL 21
#define CAM_SDA 22
#define CAM_VSYNC 23
#define CAM_HREF 25
#define CAM_D0 26
#define CAM_D1 27
#define CAM_D2 14
#define CAM_D3 12
#define CAM_D4 13
#define CAM_D5 15
#define CAM_D6 2
#define CAM_D7 0
#define CAM_RESET 4
#define CAM_PWDN 5

#define MIC_SEL 34
#define MIC_LRCL 35
#define MIC_DOUT 32
#define MIC_BCLK 33

#define IR_RECEIVER 18

#define TAKE_PHOTO 0x1FE807F
#define START_AUDIO 0x1FE40BF
#define STOP_AUDIO 0x1FE20DF

WiFiClient client;
UniversalTelegramBot bot(BOT_TOKEN, client);

IRrecv irrecv(IR_RECEIVER);
decode_results results;
WebServer server(80);
const int CS = 22;
Arducam_Mega myCAM (22);
CAM_IMAGE_MODE imageMode = CAM_IMAGE_MODE_QVGA;
uint8_t imageData = 0;
uint8_t imageDataNext = 0;
uint8_t headFlag = 0;
const size_t bufferSize = 2048;
uint8_t buffer[bufferSize] = {0};
#define VOICE_ADDRESS 0x30 // default I2C device address is 0x30 
DFRobot_VoiceRecorder_I2C voicerecorder(&Wire, VOICE_ADDRESS);
    
void setup() {
   Serial.begin(115200);
   WiFi.begin(ssid, password);
   while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.println("Connecting to WiFi...");
  }
   Serial.println("Connected to WiFi");
   irrecv.enableIRIn();
   myCAM.begin(); myCAM.takePicture(imageMode,CAM_IMAGE_PIX_FMT_JPG);
    voicerecorder.begin();  
    while(voicerecorder.begin() != 0) {
    Serial.println("i2c device number error!");
    delay(1000);
  } Serial.println("i2c connect success!");

  /**
   * Set button mode on or off
   * BUTTON_MODE_ON
   * BUTTON_MODE_OFF
   */
  voicerecorder.setButtonMode(BUTTON_MODE_ON);

  /**
   * Set light mode on or off
   * LIGHT_MODE_ON
   * LIGHT_MODE_OFF
   */
  voicerecorder.setLightMode(LIGHT_MODE_ON);

  /**
   * Set the audio number
   * VOICE_NUMBER_0
   * VOICE_NUMBER_1
   * VOICE_NUMBER_2
   * VOICE_NUMBER_3
   * VOICE_NUMBER_4
   * VOICE_NUMBER_5
   * VOICE_NUMBER_6
   * VOICE_NUMBER_7
   * VOICE_NUMBER_8
   * VOICE_NUMBER_9
   */
  if(VOICE_NONE != voicerecorder.setVoiceNumber(VOICE_NUMBER_0)){
    Serial.println("set number error, please wait!");
  }   
 }


void sendImageData(void)
{
    int i = 0;
    WiFiClient client = server.client();
    if (!client.connected()) return;
    while (myCAM.getReceivedLength())
    {
        imageData = imageDataNext;
        imageDataNext = myCAM.readByte();
        if (headFlag == 1)
        {
            buffer[i++]=imageDataNext;  
            if (i >= bufferSize)
            {
            if (!client.connected())    break;
                client.write(buffer, i);
                i = 0;
            }
        }
        if (imageData == 0xff && imageDataNext ==0xd8)
        {
            headFlag = 1;
            buffer[i++]=imageData;
            buffer[i++]=imageDataNext;  
        }
        if (imageData == 0xff && imageDataNext ==0xd9)
        {
            headFlag = 0;
            if (!client.connected()) break;
            client.write(buffer, i);
            i = 0;
            break;
        }
    }
}

void captureCallbackFunction(void)
{
    myCAM.takePicture(imageMode,CAM_IMAGE_PIX_FMT_JPG);
    WiFiClient client = server.client();
    if (!client.connected()) return;
    String response = "HTTP/1.1 200 OK\r\n";
    response += "Content-Type: image/jpeg\r\n";
    response += "Content-len: " + String(7000) + "\r\n\r\n";  
    sendImageData();
    bot.sendPhoto(CHAT_ID, "photo.jpg");

}

void streamCallbackFunction(void)
{
  WiFiClient client = server.client();
  
  String response = "HTTP/1.1 200 OK\r\n";
  response += "Content-Type: multipart/x-mixed-replace; boundary=frame\r\n\r\n";
  server.sendContent(response); 
  while(1)
  {
    myCAM.takePicture(imageMode,CAM_IMAGE_PIX_FMT_JPG);
    if (!client.connected()) break;
    response = "--frame\r\n";
    response += "Content-Type: image/jpeg\r\n\r\n";
    server.sendContent(response); 
    sendImageData();      
  }
}


void loop() {

if (irrecv.decode(&results)) {
        
  if (results.value == TAKE_PHOTO) {
  // Code to take photo with camera module
  Serial.println("Taking photo..."); 
  myCAM.takePicture(imageMode,CAM_IMAGE_PIX_FMT_JPG);
            
  String photoFileName = "photo.jpg" ;      
  bot.sendPhoto(CHAT_ID,photoFileName);  
   }
        
if (results.value == START_AUDIO) {
  // Code to start audio recording
  
Serial.println("Starting audio recording...");
 int status = voicerecorder.recordvoiceStart();
 if (status != VOICE_SUCCESS){          
Serial.println("Error starting audio revording");
      }   
   }     

if (results.value == STOP_AUDIO) {  
  // Code to stop audio recording

  Serial.println("Stopping audio recording...");
  
 int status = voicerecorder.recordVoiceEnd();
 if (status != VOICE_SUCCESS) {
    Serial.println("Error stopping audio recording");
  }     
  String audioFileName = "audio.mp3";
  bot.sendMessage(CHAT_ID, audioFileName);          
 }         

yield();
        
irrecv.resume(); 
        
  }
    
}

But unfortunately, when I upload the code to esp32, it appears to me in the serial monitor the following

10:04:09.632 -> ets Jun  8 2016 00:22:57
10:04:09.639 -> 
10:04:09.642 -> rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
10:04:09.653 -> configsip: 0, SPIWP:0xee
10:04:09.662 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:04:09.674 -> mode:DIO, clock div:1
10:04:09.680 -> load:0x3fff0018,len:4
10:04:09.684 -> load:0x3fff001c,len:928
10:04:09.689 -> ho 0 tail 12 room 4
10:04:09.693 -> load:0x40078000,len:8740
10:04:09.698 -> load:0x40080400,len:5788
10:04:09.702 -> entry 0x4008069c

But when I use a different code

#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <UniversalTelegramBot.h>
#include <Adafruit_Sensor.h>
#include <TinyGPS.h>
#include <IRremote.h>

const char* ssid = "***'******";
const char* password = "*********";

#define BOT_TOKEN "**********"
#define CHAT_ID "**********"

WiFiClient client;
UniversalTelegramBot bot(BOT_TOKEN, client);

#define CAM_SCL 21
#define CAM_SDA 22
#define CAM_VSYNC 23
#define CAM_HREF 25
#define CAM_D0 26
#define CAM_D1 27
#define CAM_D2 14
#define CAM_D3 12
#define CAM_D4 13
#define CAM_D5 15
#define CAM_D6 2
#define CAM_D7 0
#define CAM_RESET 4
#define CAM_PWDN 5

#define MIC_SEL 34
#define MIC_LRCL 35
#define MIC_DOUT 32
#define MIC_BCLK 33

#define GPS_PPS 19
#define GPS_RXD TXD0 
#define GPS_TXD RXD0

#define IR_RECEIVER 18

#define TAKE_PHOTO 0x1FE807F
#define START_AUDIO 0x1FE40BF
#define STOP_AUDIO 0x1FE20DF
#define START_VIDEO 0x1FEC03F
#define STOP_VIDEO 0x1FE20DF
#define GET_LOCATION 0x1FEF807


IRrecv irrecv(IR_RECEIVER);
decode_results results;

TinyGPS gps;

void setup() {

Serial.begin(115200);

WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}

Serial.println("Connected to WiFi");

irrecv.enableIRIn();

}

void loop() {

if (irrecv.decode(&results)) {
  if (results.value == TAKE_PHOTO) {
  // Code to take photo with camera module
  Serial.println("Taking photo..."); 
  
  // Code to send photo to Telegram bot
  bot.sendMessage(CHAT_ID, "Photo", "");
}

if (results.value == START_AUDIO) {
  // Code to start audio recording
  
  Serial.println("Starting audio recording...");
}

if (results.value == STOP_AUDIO) {  
  // Code to stop audio recording

  Serial.println("Stopping audio recording...");
  
  // Code to send audio clip to Telegram bot
  bot.sendMessage(CHAT_ID, "Audio", "");    
}

if (results.value == START_VIDEO) {
  // Code to start video recording
  
  Serial.println("Starting video recording...");
}

if (results.value == STOP_VIDEO) {
  // Code to stop video recording
  
  Serial.println("Stopping video recording...");

  // Code to send video to Telegram bot  
  bot.sendMessage(CHAT_ID, "Video", "");   
}

if (results.value == GET_LOCATION) {
  Serial.println("Getting GPS location...");
  
  // Code to get GPS location 
  
  // Code to send location to Telegram bot
  bot.sendMessage(CHAT_ID, "Location", "");
}

irrecv.resume(); 
}

} 

It actually sends the word when you press the button and it works correctly unlike the first code.
All I want is code that sends me the actual data to the telegram bot.

Your topic has been moved to the Programming category of the forum

How many of your recent "new topics" are actually about this same project? I ask, because there are many similarities. Do you really want us to ask all the same questions as in the other topics?

Format your code. Upload a block diagram.

Try giving more time for the WiFi to complete handshaking. and report observations (no change, any change, et c.).