[PR-70]: Added the ability to send DMs from bot accounts#129
Open
Kshitij-Katiyar wants to merge 9 commits into
Open
[PR-70]: Added the ability to send DMs from bot accounts#129Kshitij-Katiyar wants to merge 9 commits into
Kshitij-Katiyar wants to merge 9 commits into
Conversation
…ing to channels Signed-off-by: Paul Rothrock <paul@movetoiceland.com>
mickmister
reviewed
Apr 23, 2024
mickmister
left a comment
Contributor
There was a problem hiding this comment.
Thanks @Kshitij-Katiyar 👍
In general LGTM, just some comments for discussion
| { | ||
| "TeamName": "your-team-name", | ||
| "DelayInSeconds": 3, | ||
| "IncludeGuests": false, |
Contributor
There was a problem hiding this comment.
We're removing a piece of data here, the IncludeGuests property
| if err := p.handleDMs(action, channelName); err != nil { | ||
| p.API.LogError("failed to handle DM channel, continuing to next channel. " + err.Error()) | ||
| } | ||
| } else { // Otherwise treat it like a normal channel |
Contributor
There was a problem hiding this comment.
Can return here instead of having the else?
Comment on lines
+259
to
+261
| if !dmUser.IsBot { | ||
| return errors.Wrapf(userErr, "Specified DM user is not a bot for username %s", username) | ||
| } |
|
|
||
| func (p *Plugin) handleDMs(action *Action, channelName string) error { | ||
| username := channelName[1:] | ||
| dmUser, userErr := p.API.GetUserByUsername(username) |
Contributor
There was a problem hiding this comment.
We should use p.client instead of p.API whenever possible
Comment on lines
+268
to
+271
| dmMessage := "Welcome to the team!" | ||
| if len(action.Context.DirectMessagePost) != 0 { | ||
| dmMessage = action.Context.DirectMessagePost | ||
| } |
Contributor
There was a problem hiding this comment.
Should we make this required instead? "Welcome to the team!" seems not too useful
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I added the ability to send a DM from a bot account. Any channel name that starts with an @ symbol that is also a bot user will have a DM sent with the message configured in the Action's ActionDirectMessagePost.
This PR is the extension of the PR #70.