Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for slash commands and interactive msg #100

Merged
merged 5 commits into from
Jul 1, 2022

Conversation

k321rf
Copy link
Contributor

@k321rf k321rf commented Feb 28, 2022

Add support for slash commands within CommandDefinition.

Add support for interactive events as part of the CommandDefinition.

func wasArticleUseFulCmd(actionId string) func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
	return func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
        ....
        }
}

func wasArticleUseFulInteractive(s *slacker.Slacker, e *socketmode.Event, callback *slack.InteractionCallback, request *socketmode.Request) {
...
}

func main() {
  bot := slacker.NewClient(....)
  bot.Command("was-this-article-useful", &slacker.CommandDefinition{
		  BlockID:     "was_article_useful",
		  Handler:     wasArticleUseFulCmd("was_article_useful"),
		  Interactive: wasArticleUseFulInteractive,
	  })
}

@k321rf
Copy link
Contributor Author

k321rf commented Feb 28, 2022

This PR is similar to #88 and also tries to solve the issue #71.

@ctennis
Copy link

ctennis commented Mar 28, 2022

I'm happy to let this one go forward and redact my proposed PR :)

@arusso
Copy link
Collaborator

arusso commented Mar 28, 2022 via email

@mrmm
Copy link

mrmm commented Jun 19, 2022

Hello @arusso, I hope that everything went great with the review. Is there a way to help move this PR forward?

Copy link
Collaborator

@arusso arusso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission!

Could you provide a minimal example that one can run to exercise the code to go with this?

Once you make the field changes and provide a minimal example we can finally get this merged.

Thanks!

context.go Outdated
@@ -55,9 +55,15 @@ type MessageEvent struct {
// Channel ID where the message was sent
Channel string

// ChannelName where the message was sent
ChannelName func() string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other struct fields are strings, for the sake of consistency ChannelName and UserName should be as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context.go Outdated
// User ID of the sender
User string

// UserName of the the sender
UserName func() string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a a string field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slacker.go Outdated Show resolved Hide resolved
The channel name and username is fetch eager as part of the slack
message parsing to have a clear and consistent MessageEvent struct.
Copy link
Contributor Author

@k321rf k321rf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the eager implementation for fetching the channel name and username.

@arusso arusso merged commit 313e72e into shomali11:master Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants