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
533 B
27 lines
533 B
3 years ago
|
package telegram
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/go-faster/errors"
|
||
|
|
||
|
"github.com/gotd/td/tg"
|
||
|
)
|
||
|
|
||
|
// Self returns current user.
|
||
|
//
|
||
|
// You can use tg.User.Bot to check whether current user is bot.
|
||
|
func (c *Client) Self(ctx context.Context) (*tg.User, error) {
|
||
|
users, err := c.tg.UsersGetUsers(ctx, []tg.InputUserClass{&tg.InputUserSelf{}})
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
user, ok := tg.UserClassArray(users).FirstAsNotEmpty()
|
||
|
if !ok {
|
||
|
return nil, errors.Errorf("users response count: %v", users)
|
||
|
}
|
||
|
|
||
|
return user, nil
|
||
|
}
|