【发布时间】:2019-06-17 20:49:19
【问题描述】:
我无法解决我的 Spring Boot 应用程序的问题,我尝试创建自己的 Telegram 机器人。 创建 Spring 容器并启动应用程序后,我在日志中看到相同的错误: Error logs
2019-06-17 23:26:33.117 错误 3340 --- [gram Connection] Telegram Bots Api:BOTSESSION
public TelegramBot(BotProperties botProperties) {
this.botProperties = botProperties;
}
@PostConstruct
public void init() {
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
try {
telegramBotsApi.registerBot(new TelegramBot(botProperties));
logger.info("bot successfully register");
} catch (TelegramApiException e) {
logger.error(e.getMessage(), e);
}
}
@Override
public void onUpdateReceived(Update update) {
if (update.hasMessage()) {
System.out.println(update.getMessage().getText());
}
}
@Override
public String getBotUsername() {
return botProperties.getBotName();
}
@Override
public String getBotToken() {
return botProperties.getBotToken();
}
}
主类:
public class TelegramApplication {
public static void main(String[] args) {
ApiContextInitializer.init();
SpringApplication.run(TelegramApplication.class, args);
}
}
【问题讨论】:
标签: java spring maven spring-boot telegram