synapsecns / sanguine

Synapse Monorepo
MIT License
35 stars 25 forks source link

[opbot] disable link unfurl #2785

Closed trajan0x closed 1 week ago

trajan0x commented 2 weeks ago

See slack-io/slacker#11

Add an option to the slacker lib to allow link unfurls to be disabled.

Something like this: https://app.greptile.com/share/9488bed2-1f06-4447-9587-cdf4021a05b4

greptile-apps[bot] commented 2 weeks ago

To add an option to disable link unfurls in the slacker library, follow these steps:

  1. Update config.go:
// Add a new field to the Config struct
UnfurlLinks bool `yaml:"unfurl_links"`
  1. Update commands.go:
// After unmarshalling the config file, add a check for the new field
if cfg.UnfurlLinks {
    // Pass the unfurl links option to the bot
    botServer := botmd.NewBot(metrics.Get(), cfg, slacker.WithUnfurlLinks(cfg.UnfurlLinks))
} else {
    botServer := botmd.NewBot(metrics.Get(), cfg)
}
  1. Update botmd.go:
// Modify the NewBot function to accept the new option
func NewBot(handler metrics.Handler, cfg config.Config, options ...slacker.Option) Bot {
    server := slacker.NewClient(cfg.SlackBotToken, cfg.SlackAppToken, options...)
    bot := Bot{
        handler: handler,
        cfg:     cfg,
        server:  server,
    }

    bot.signozClient = signoz.NewClientFromUser(handler, cfg.SignozBaseURL, cfg.SignozEmail, cfg.SignozPassword)

    bot.addCommands(bot.traceCommand(), bot.rfqLookupCommand())

    return bot
}

These changes will allow the bot to disable link unfurls based on the configuration.

References

/contrib/opbot/cmd/commands.go /contrib/opbot/config/config.go /contrib/opbot/botmd/botmd.go /contrib/opbot

Ask Greptile