请告诉我为什么我的程序在启动后立即结束。这是我家用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