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();
}

Answer

I found how do this:

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

For unpin message use UnpinChatMessage.



Source: stackoverflow