You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
552 B
27 lines
552 B
3 years ago
|
package auth
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/go-faster/errors"
|
||
|
|
||
|
"github.com/gotd/td/tg"
|
||
|
)
|
||
|
|
||
|
// Bot performs bot authentication request.
|
||
|
func (c *Client) Bot(ctx context.Context, token string) (*tg.AuthAuthorization, error) {
|
||
|
auth, err := c.api.AuthImportBotAuthorization(ctx, &tg.AuthImportBotAuthorizationRequest{
|
||
|
APIID: c.appID,
|
||
|
APIHash: c.appHash,
|
||
|
BotAuthToken: token,
|
||
|
})
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
result, err := checkResult(auth)
|
||
|
if err != nil {
|
||
|
return nil, errors.Wrap(err, "check")
|
||
|
}
|
||
|
return result, nil
|
||
|
}
|