From 1dfd1df1f07c71e47aee260ebb0b70f44b3276ea Mon Sep 17 00:00:00 2001 From: Lorenzo Aiello Date: Sun, 14 Jul 2024 18:48:28 -0700 Subject: [PATCH] docs: Adding an example for ConversationHistory (#1302) --- .../conversation_history.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/conversation_history/conversation_history.go diff --git a/examples/conversation_history/conversation_history.go b/examples/conversation_history/conversation_history.go new file mode 100644 index 000000000..569c12d68 --- /dev/null +++ b/examples/conversation_history/conversation_history.go @@ -0,0 +1,23 @@ +package main + +import ( + "context" + "fmt" + + "github.com/slack-go/slack" +) + +func main() { + api := slack.New("YOUR_TOKEN") + params := slack.GetConversationHistoryParameters{ + ChannelID: "C0123456789", + } + messages, err := api.GetConversationHistoryContext(context.Background(), ¶ms) + if err != nil { + fmt.Printf("%s\n", err) + return + } + for _, message := range messages.Messages { + fmt.Printf("Message: %s\n", message.Attachments[0].Color) + } +}