Lightweight
TeleightBots is designed to be lightweight and as efficient as possible.
Just add the TeleightBots dependency to your project and add the following code to your main class:
final String botToken = "your_bot_token_here"; // <-- The bot token from @BotFather
final String botUsername = "your_bot_username_here"; // <-- The bot username
// You custom listener. In this example, we are printing the event whether a generic update is received.
final EventListener<UpdateReceivedEvent> updateEvent = EventListener.ofBuilder(UpdateReceivedEvent.class)
.handler(event -> System.out.println("UpdateReceivedEvent: " + event.bot().getBotUsername() + " -> " + event))
.build();
// Register the bot
TeleightBots.getBotManager().registerLongPolling(botToken, botUsername, bot -> {
bot.getEventManager().addListener(updateEvent);
}
And you're good to go!