feat: sync implement Stars friend gift packages

This commit is contained in:
iamxvbaba 2026-08-02 01:51:02 +08:00
parent 3a123f38db
commit c854fc7b94
15 changed files with 914 additions and 1 deletions

View file

@ -507,6 +507,9 @@ func tgPrivateMessageUpdates(event domain.UpdateEvent, msg domain.Message, rando
Pts: event.Pts,
PtsCount: event.PtsCount,
})
if balance := tgGiftStarsBalanceUpdate(msg); balance != nil {
updates = append(updates, balance)
}
date := event.Date
if date == 0 {
date = msg.Date
@ -520,6 +523,18 @@ func tgPrivateMessageUpdates(event domain.UpdateEvent, msg domain.Message, rando
}
}
func tgGiftStarsBalanceUpdate(msg domain.Message) tg.UpdateClass {
if msg.Out || msg.Media == nil || msg.Media.ServiceAction == nil ||
msg.Media.ServiceAction.Kind != domain.MessageServiceActionGiftStars {
return nil
}
action := msg.Media.ServiceAction.GiftStars
if action == nil || action.BalanceAfter < 0 {
return nil
}
return &tg.UpdateStarsBalance{Balance: &tg.StarsAmount{Amount: action.BalanceAfter}}
}
// tgPrivateSendResultUpdates returns a complete send acknowledgement for exact
// random_id replays. DrKLO requires UpdateNewMessage in an Updates response to
// transition its local pending message to SENT. Visible edited messages use the