Skip to content

Commit

Permalink
feat: slacker now handles unfurling option + main.go for testing purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
kathiouchka committed Jun 28, 2024
1 parent e993082 commit 4c02642
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
39 changes: 39 additions & 0 deletions examples/message-unfurl/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// main.go

package main

import (
"context"
"log"
"os"

"github.com/slack-io/slacker"
)

// Defining commands using slacker

func main() {
bot := slacker.NewClient(os.Getenv("SLACK_BOT_TOKEN"), os.Getenv("SLACK_APP_TOKEN"))

bot.AddCommand(&slacker.CommandDefinition{
Command: "without",
Handler: func(ctx *slacker.CommandContext) {
ctx.Response().Reply("https://signoz.io/", slacker.WithUnfurlLinks(false))
},
})

bot.AddCommand(&slacker.CommandDefinition{
Command: "with",
Handler: func(ctx *slacker.CommandContext) {
ctx.Response().Reply("https://signoz.io/")
},
})

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := bot.Listen(ctx)
if err != nil {
log.Fatal(err)
}
}
4 changes: 2 additions & 2 deletions response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ func (r *Writer) post(channel string, message string, blocks []slack.Block, opti
opts = append(opts, slack.MsgOptionSchedule(postAt))
}

// response_writer.go
if postOptions.UnfurlLinks != nil {
if !*postOptions.UnfurlLinks {
opts = append(opts, slack.MsgOptionDisableLinkUnfurl())
fmt.Println("unfurls are disabled")
opts = append(opts, slack.MsgOptionDisableLinkUnfurl(), slack.MsgOptionDisableMediaUnfurl())
}
}

Expand Down

0 comments on commit 4c02642

Please sign in to comment.