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

When I send a message to the bot, it replies via the default slackbot #785

Closed
descholar-ceo opened this issue Aug 19, 2020 · 1 comment
Closed

Comments

@descholar-ceo
Copy link
Contributor

Here are my codes of handling MessageEvent:

func handleMsgFromSlack(event *slack.MessageEvent) {
	user, err := slackClient.GetUserInfo(event.User)
	attachment := slack.Attachment{
		Pretext: "Hello @" + user.Name + "",
		Text:    "I am happy to see you here!",

		Fields: []slack.AttachmentField{
			slack.AttachmentField{
				Title: "Title of the attachment",
				Value: "This is the body",
			},
		},
	}

	channelID, timestamp, err := slackClient.PostMessage(
		event.User,
		slack.MsgOptionText("Hello there!", true),
		slack.MsgOptionAttachments(attachment),
	)

	if err != nil {
		fmt.Printf("Ooops! There is an error: %s\n", err)
		return
	}
	fmt.Printf("Message successfully sent to channel %s at %s", channelID, timestamp)
}

The above codes work, but in a wrong way; When a user sends a message to the bot, it replies using the default slackbot. The response is not coming via the bot itself. I think that's bug.

@kanata2
Copy link
Member

kanata2 commented Aug 19, 2020

You can use slack.MsgOptionAsUser(true).

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

No branches or pull requests

2 participants