如何使用 simple-slack-api 读取频道消息?

How to read channel messages with simple-slack-api?

我正在使用 simple-slack-api 和 Java,但我找不到从特定频道读取消息的方法。我的代码如下:

public void getChannelMessages(String channelName) throws IOException{

    SlackChannel channel = slackSession_.findChannelByName(channelName);


}

要从频道读取消息,您需要获取该频道的历史记录。

来自示例:

    /**
     * This method how to get the message history from a given channel (by default, 1000 max messages are fetched)
     */
    public void fetchSomeMessagesFromChannelHistory(SlackSession session, SlackChannel slackChannel)
    {
        //build a channelHistory module from the slack session
        ChannelHistoryModule channelHistoryModule = ChannelHistoryModuleFactory.createChannelHistoryModule(session);

        List<SlackMessagePosted> messages = channelHistoryModule.fetchHistoryOfChannel(slackChannel.getId());
}

有关详细信息,请参阅 git 中的 full example