From 7f2c0d0d70e66477dc018febf4613d8971e55453 Mon Sep 17 00:00:00 2001 From: Lorenzo Aiello Date: Sun, 14 Jul 2024 18:37:30 -0700 Subject: [PATCH] docs: Adding an example for ConversationHistory --- .../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) + } +}