Skip to content
Advertisement

How to pin message using AbilityBot in TelegramBots library (Java)?

I searched in google and docs of library, but nothing found.

official TelegramBots library docs

I need some like this:

public Ability sayHelloWorld() {
    return Ability
              .builder()
              .name("hello")
              .info("says hello world!")
              .locality(ALL)
              .privacy(PUBLIC)
              .action(ctx -> {
                       Message msg = silent.send("Hello world!", ctx.chatId()).get();
                       // example of method which i can't find
                       silent.pin(msg.getChatId(), msg.getMessageId())
              })
              .build();
}

Advertisement

Answer

I found how do this:

sendApiMethodAsync(PinChatMessage.builder()
            .chatId(msg.getChatId().toString())
            .messageId(msg.getMessageId())
            .build())

For unpin message use UnpinChatMessage.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement