java - 如何在 TelegramBots 库(Java)中使用 AbilityBot 固定消息?
问题描述
我在谷歌和图书馆的文档中搜索,但没有找到。
我需要一些这样的:
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();
}
解决方案
我发现如何做到这一点:
sendApiMethodAsync(PinChatMessage.builder()
.chatId(msg.getChatId().toString())
.messageId(msg.getMessageId())
.build())
对于取消固定消息,请使用 UnpinChatMessage。
推荐阅读
- android-studio - 应用程序元素未显示在设计预览中
- c++ - 无法调用结构内的成员函数指针
- amazon-web-services - 时间戳未从 Glue 加载到 Redshift 表中
- c# - 从 object[,] 数组 c# 中删除空元素
- google-drive-api - 尝试使用nodejs和curl(alt = media)从驱动器下载jpg但没有成功
- c++ - 将 UDP 包发送到 Lifx 和 recvfrom
- tensorflow - 将输出张量连接到张量流中的占位符
- php - 如何使用 Guzzle 进行这项工作
- c# - 当实体框架中的模型更改时删除并创建受影响的表
- python - Python Beautiful Soup“隐藏”表