-
Notifications
You must be signed in to change notification settings - Fork 41
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
[PR-70]: Added the ability to send DMs from bot accounts #129
base: master
Are you sure you want to change the base?
Conversation
…ing to channels Signed-off-by: Paul Rothrock <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Kshitij-Katiyar 👍
In general LGTM, just some comments for discussion
{ | ||
"TeamName": "your-team-name", | ||
"DelayInSeconds": 3, | ||
"IncludeGuests": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can return here instead of having the else
?
if !dmUser.IsBot { | ||
return errors.Wrapf(userErr, "Specified DM user is not a bot for username %s", username) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
func (p *Plugin) handleDMs(action *Action, channelName string) error { | ||
username := channelName[1:] | ||
dmUser, userErr := p.API.GetUserByUsername(username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use p.client
instead of p.API
whenever possible
dmMessage := "Welcome to the team!" | ||
if len(action.Context.DirectMessagePost) != 0 { | ||
dmMessage = action.Context.DirectMessagePost | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this required instead? "Welcome to the team!" seems not too useful
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.