slack-ruby / slack-ruby-client

A Ruby and command-line client for the Slack Web, Real Time Messaging and Event APIs.
MIT License
1.21k stars 214 forks source link

Parse conversations_history response #383

Closed hallz11 closed 3 years ago

hallz11 commented 3 years ago

Hi, I would like to know how to parse the response for client.conversations_history request. I usually use JSON.parse and loop the messages. But, I cannot do that for this case since the response looks like this:

channel_actions_count=0, channel_actions_ts=, has_more=true, messages=[#<Slack::Messages::Message attachments=#<Hashie::Array [#<Slack::Messages::Message actions=#<Hashie::Array [#<Slack::Messages::Message id="1" style="" text=""
....

Thank you.

dblock commented 3 years ago

I don't think you need to parse anything, the library does it for you. In this code I am just doing .messages and you get back a collection of Slack::Messages::Message.

Does this help?

hallz11 commented 3 years ago

Hi, yes it helps. Sorry my bad not noticing that. Thank you for the help.