Skip to content

Commit

Permalink
LEADERBOARD FEATURE
Browse files Browse the repository at this point in the history
  • Loading branch information
jade-vogt committed Sep 17, 2023
1 parent 93f7c3d commit 21be0ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>best.tigers</groupId>
<artifactId>tigersbot</artifactId>
<version>1.3.5</version>
<version>1.3.7</version>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/best/tigers/tigersbot/services/BotService.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ private void processUpdate(Update update) {
sendHelpMessage(message);
return;
}
if (message.text().equals("/leaderboard")) {
sendLeaderboardMessage(message);
return;
}
var handlers = getHandlers(message);
for (var handler : handlers) {
if (handler.invokationTest(message)) {
Expand Down Expand Up @@ -94,12 +98,19 @@ private void sendHelpMessage(Message message) {
handlerFactories.forEach(f -> {
helpBuilder.append("\n").append(f.getHelp());
});
helpBuilder.append("\n").append("<b>/leaderboard</b>\n<i>get the leaderboard link</i>");
helpBuilder.append("\n").append("<b>/help</b>\n<i>show this help message</i>");
var msg = new SendMessage(message.chat().id(), helpBuilder.toString());
msg.parseMode(ParseMode.HTML);
bot.execute(msg);
}

private void sendLeaderboardMessage(Message message) {
var leaderboardUrl = "https://kibana.tigers.best:8443/s/public/app/dashboards?auth_provider_hint=anonymous1#/view/7e1165b7-624c-4e14-8c38-ca26b0a69dcd?_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A60000)%2Ctime%3A(from%3Anow-1y%2Fd%2Cto%3Anow))";
var msg = new SendMessage(message.chat().id(), leaderboardUrl);
bot.execute(msg);
}

public void registerHandlerFactory(AbstractHandlerFactory factory) {
factory.setTelegramBot(bot);
handlerFactories.add(factory);
Expand Down

0 comments on commit 21be0ab

Please sign in to comment.