0

Can you help me? Please I can`t understand... I want to override a method and according to the video course, I need to create a variable of type long and place it inside the method But Idea scolds me that it should be String and not long

chat_id - this variable does not accept the idea and swears that I should put a String type there

Please help me... Thanks in advance

@Override
    public BotApiMethod<?> onWebhookUpdateReceived(Update update) {
        if (update.getMessage() != null && update.getMessage().hasText()) {
            **long chat_id = update.getMessage().getChatId();**

            try {
                execute(new SendMessage(**chat_id**, "Hi! " + update.getMessage().getText()));
            } catch (TelegramApiException e) {
                e.printStackTrace();
            }
        }

        return null;
    }

my import

import org.telegram.telegrambots.bots.DefaultBotOptions;
import org.telegram.telegrambots.bots.TelegramWebhookBot;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

And my Gradle

    dependencies {
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.6.2'
    compileOnly 'org.projectlombok: lombok'
    annotationProcessor 'org.projectlombok:lombok'

    implementation group: 'org.telegram', name: 'telegrambots-spring-boot-starter', version: '4.4.0.2'
    implementation group: 'org.telegram', name: 'telegrambots', version: '5.6.0'

}```

1 Answers1

0

Yep, now this variable must be a String type.

sendMessage.setChatId(String.valueOf(update.getMessage().getChatId()));