Skip to content

[PR-70]: Added the ability to send DMs from bot accounts#129

Open
Kshitij-Katiyar wants to merge 9 commits into
masterfrom
PR_70
Open

[PR-70]: Added the ability to send DMs from bot accounts#129
Kshitij-Katiyar wants to merge 9 commits into
masterfrom
PR_70

Conversation

@Kshitij-Katiyar

Copy link
Copy Markdown
Contributor

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.

@Kshitij-Katiyar Kshitij-Katiyar changed the title Pr 70 [PR-70]: Added the ability to send DMs from bot accounts Apr 15, 2024
@mickmister
mickmister requested a review from ayusht2810 April 23, 2024 21:33

@mickmister mickmister left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread README.md Outdated
Comment thread README.md
{
"TeamName": "your-team-name",
"DelayInSeconds": 3,
"IncludeGuests": false,

Copy link
Copy Markdown
Contributor

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

Comment thread server/welcomebot.go
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

Copy link
Copy Markdown
Contributor

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?

Comment thread server/welcomebot.go
Comment on lines +259 to +261
if !dmUser.IsBot {
return errors.Wrapf(userErr, "Specified DM user is not a bot for username %s", username)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Comment thread server/welcomebot.go

func (p *Plugin) handleDMs(action *Action, channelName string) error {
username := channelName[1:]
dmUser, userErr := p.API.GetUserByUsername(username)

Copy link
Copy Markdown
Contributor

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

Comment thread server/welcomebot.go
Comment on lines +268 to +271
dmMessage := "Welcome to the team!"
if len(action.Context.DirectMessagePost) != 0 {
dmMessage = action.Context.DirectMessagePost
}

Copy link
Copy Markdown
Contributor

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

@mickmister
mickmister requested a review from hanzei April 23, 2024 21:41
@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Apr 24, 2024
@hanzei
hanzei removed their request for review April 24, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants