diff --git a/ext/context.go b/ext/context.go index 0a1dc1a..8084971 100644 --- a/ext/context.go +++ b/ext/context.go @@ -693,7 +693,7 @@ func (ctx *Context) extractContactResolvedPeer(p *tg.ContactsResolvedPeer, err e functions.SavePeersFromClassArray(ctx.PeerStorage, p.Chats, p.Users) switch p.Peer.(type) { case *tg.PeerChannel: - if p.Chats == nil || len(p.Chats) == 0 { + if len(p.Chats) == 0 { return &types.EmptyUC{}, errors.New("peer info not found in the resolved Chats") } switch chat := p.Chats[0].(type) { @@ -704,7 +704,7 @@ func (ctx *Context) extractContactResolvedPeer(p *tg.ContactsResolvedPeer, err e return &types.EmptyUC{}, errors.New("peer could not be resolved because Channel Forbidden") } case *tg.PeerUser: - if p.Users == nil || len(p.Users) == 0 { + if len(p.Users) == 0 { return &types.EmptyUC{}, errors.New("peer info not found in the resolved Chats") } switch user := p.Users[0].(type) { @@ -814,8 +814,8 @@ func (ctx *Context) DownloadMedia(media tg.MessageMediaClass, downloadOutput Dow return downloadOutput.run(ctx, d) } -func (ctx *Context) TransferStarGift(msgId int, toId int64) (tg.UpdatesClass, error) { - peerUser := ctx.PeerStorage.GetPeerById(toId) +func (ctx *Context) TransferStarGift(chatId int64, msgId int) (tg.UpdatesClass, error) { + peerUser := ctx.PeerStorage.GetPeerById(chatId) if peerUser == nil { return nil, mtp_errors.ErrPeerNotFound } diff --git a/generic/gen_cu.go b/generic/gen_cu.go index 66301ea..ca5a791 100755 --- a/generic/gen_cu.go +++ b/generic/gen_cu.go @@ -238,3 +238,14 @@ func GetUserProfilePhotos[chatUnion ChatUnion](ctx *ext.Context, user chatUnion, return ctx.GetUserProfilePhotos(userId, opts) } + +// TransferStarGift is a generic helper for ext.Context.TransferStarGift method. +func TransferStarGift[chatUnion ChatUnion](ctx *ext.Context, chat chatUnion, msgId int) (tg.UpdatesClass, error) { + + chatId, err := getIdByUnion(ctx, chat) + if err != nil { + return nil, err + } + + return ctx.TransferStarGift(chatId, msgId) +}