首页 > 解决方案 > 如何在 TelegramBots 库(Java)中使用 AbilityBot 固定消息?

问题描述

我在谷歌和图书馆的文档中搜索,但没有找到。

TelegramBots 官方库文档

我需要一些这样的:

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

标签: javabotstelegramtelegram-bot

解决方案


我发现如何做到这一点:

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

对于取消固定消息,请使用 UnpinChatMessage。


推荐阅读