Last active
August 25, 2021 05:19
-
-
Save arusso/d07ff40de0868ca6ca89e52e6ea25dbb to your computer and use it in GitHub Desktop.
Attempt to reproduce duplicate messages with threads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"os" | |
"github.com/shomali11/slacker" | |
"github.com/slack-go/slack/socketmode" | |
) | |
func main() { | |
bot := slacker.NewClient( | |
os.Getenv("SLACK_BOT_TOKEN"), | |
os.Getenv("SLACK_APP_TOKEN"), | |
) | |
// set socketmode to debug | |
socketmode.OptionDebug(true)(bot.SocketMode()) | |
definition := &slacker.CommandDefinition{ | |
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) { | |
fmt.Println(botCtx.Event().BotID) | |
image := request.Param("image") | |
response.Reply(fmt.Sprintf("%s promoted here", image), slacker.WithThreadReply(true)) | |
}, | |
} | |
bot.Command("promote <image>", definition) | |
ctx, cancel := context.WithCancel(context.Background()) | |
defer cancel() | |
err := bot.Listen(ctx) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module github.com/arusso/socket-mode-example | |
go 1.16 | |
require ( | |
github.com/shomali11/slacker v0.0.0-20210820202715-e3dbcff4056e | |
github.com/slack-go/slack v0.9.1 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment