TelegramBots (Java) plugin for TOP.TL — automatically post bot stats and check user votes.
<dependency>
<groupId>tl.top</groupId>
<artifactId>toptl-java-telegram-bot</artifactId>
<version>1.0.0</version>
</dependency>import tl.top.toptl.TopTLClient;
import tl.top.toptl.telegram.TopTLExtension;
public class MyBot extends TelegramLongPollingBot {
private final TopTLExtension toptl;
public MyBot() {
TopTLClient client = new TopTLClient("your-toptl-token");
toptl = new TopTLExtension(client, "my_bot");
}
@Override
public void onUpdateReceived(Update update) {
toptl.handleUpdate(update);
// Check if user voted
if (update.hasMessage()) {
boolean voted = toptl.hasVoted(update.getMessage().getFrom().getId());
}
}
// Don't forget to call toptl.shutdown() when your bot stops
}MIT