为什么程序启动后立即关闭?

时间:2018-12-15 16:39:24

标签: java bots telegram webhooks

请告诉我为什么我的程序在启动后立即结束。这是我家用PC上运行的Java Telegram Bot。我使用Maven创建了项目。

MainClass

public class MainClass extends TelegramWebhookBot {
    BootConfig cfg = new BootConfig();
    public static void main(String[] args) {
        ApiContextInitializer.init();
        TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
        try {
            telegramBotsApi.registerBot(new MainClass());
        } catch (TelegramApiException ex) {
            ex.printStackTrace();
        }
    }
    @Override
    public BotApiMethod onWebhookUpdateReceived(Update update) {
        if (update.hasMessage() && update.getMessage().hasText()) {
            SendMessage sendMessage = new SendMessage();
            sendMessage.setChatId(update.getMessage().getChatId().toString());
            sendMessage.setText("Well, all information looks like noise until you break the code.");
            return sendMessage;
        }
        return null;
    }
    @Override
    public String getBotUsername() {
        return cfg.WEBHOOK_USER;
    }

    @Override
    public String getBotToken() {
        return cfg.WEBHOOK_TOKEN;
    }
    @Override
    public String getBotPath() {
        return cfg.WEBHOOK_USER;
    }


}

BootConfig类:

public class BootConfig {

        public static final String WEBHOOK_TOKEN = "555277071:AAEe9iqk-ajn2H0bzFtGifgjdfh37685689465645767nGN7TLvI";
        public static final String WEBHOOK_USER = "archopobbkbot";

控制台输出:

Process finished with exit code 0

0 个答案:

没有答案