package org.jebot.handler.impl;

import com.pengrad.telegrambot.request.SendMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.jebot.constant.Constant;
import org.jebot.handler.AbstractHandler;
import org.jebot.handler.dto.BotMessage;

@Slf4j
public class IdHandler extends AbstractHandler {

    @Override
    public boolean msgHandler(BotMessage botMessage) {
        String text = botMessage.getMessage().text();
        if (Strings.isNotEmpty(text) && text.equals(Constant.QUERY_GROUP_ID)) {
            // 获取群组 ID
            Long chatId = botMessage.getMessage().chat().id();

            // 将群组 ID 发回
            SendMessage sendMessage = new SendMessage(chatId, "群组 ID: " + chatId);
            botMessage.getTelegramBot().execute(sendMessage);
            return true;
        }
        return false;
    }
}
