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 GetSenderInfo function to get message sender info #58

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

risboo6909
Copy link

So I missed the feature to get an email address of the user sending message to my bot.

Opening PR, because this feature may be helpful for other people.

Usage pattern is like this (I omitted errors handling for simplicity):

act, _ := s.bot.ParseRequest(ctx, req)
senderInfo, _ := s.bot.GetSenderInfo(ctx, act)

senderInfo will contain user info (including email address, id, name, etc).

Copy link
Member

@PrasadG193 PrasadG193 left a comment

Choose a reason for hiding this comment

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

@risboo6909, thanks for the PR. Do you mind adding a sample/example under sample dir?

Comment on lines +76 to +91
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)

httpClient := &http.Client{}
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}

return body, nil
Copy link
Member

Choose a reason for hiding this comment

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

can we use client.sendRequest() method to avoid duplicate code?

Comment on lines +99 to +101

return resp, nil

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return resp, nil
return resp, nil

[nit] unnecessary new lines

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

2 participants