Skip to content

Commit

Permalink
implement bot api 7.7 (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
Apolisk authored Aug 10, 2024
1 parent 7655e7a commit 0442831
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ func TestBotProcessUpdate(t *testing.T) {
assert.NotNil(t, c.Message().Payment)
return nil
})
b.Handle(OnRefund, func(c Context) error {
assert.NotNil(t, c.Message().RefundedPayment)
return nil
})
b.Handle(OnAddedToGroup, func(c Context) error {
assert.NotNil(t, c.Message().GroupCreated)
return nil
Expand Down Expand Up @@ -334,6 +338,7 @@ func TestBotProcessUpdate(t *testing.T) {
b.ProcessUpdate(Update{Message: &Message{Venue: &Venue{}}})
b.ProcessUpdate(Update{Message: &Message{Invoice: &Invoice{}}})
b.ProcessUpdate(Update{Message: &Message{Payment: &Payment{}}})
b.ProcessUpdate(Update{Message: &Message{RefundedPayment: &RefundedPayment{}}})
b.ProcessUpdate(Update{Message: &Message{Dice: &Dice{}}})
b.ProcessUpdate(Update{Message: &Message{GroupCreated: true}})
b.ProcessUpdate(Update{Message: &Message{UserJoined: &User{ID: 1}}})
Expand Down
3 changes: 3 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ type Message struct {
// Message is a service message about a successful payment.
Payment *Payment `json:"successful_payment"`

// Message is a service message about a refunded payment, information about the payment.
RefundedPayment *RefundedPayment `json:"refunded_payment"`

// For a service message, a user was shared with the bot.
UserShared *RecipientShared `json:"users_shared,omitempty"`

Expand Down
8 changes: 8 additions & 0 deletions payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ type Payment struct {
ProviderChargeID string `json:"provider_payment_charge_id"`
}

type RefundedPayment struct {
Currency string `json:"currency"`
TotalAmount int `json:"total_amount"`
InvoicePayload string `json:"invoice_payload"`
TelegramChargeID string `json:"telegram_payment_charge_id"`
ProviderChargeID string `json:"provider_payment_charge_id"`
}

// PreCheckoutQuery contains information about an incoming pre-checkout query.
type PreCheckoutQuery struct {
Sender *User `json:"from"`
Expand Down
1 change: 1 addition & 0 deletions telebot.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
OnDice = "\adice"
OnInvoice = "\ainvoice"
OnPayment = "\apayment"
OnRefund = "\arefund"
OnGame = "\agame"
OnPoll = "\apoll"
OnPollAnswer = "\apoll_answer"
Expand Down
5 changes: 4 additions & 1 deletion update.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ func (b *Bot) ProcessUpdate(u Update) {
b.handle(OnPayment, c)
return
}

if m.RefundedPayment != nil {
b.handle(OnRefund, c)
return
}
if m.TopicCreated != nil {
b.handle(OnTopicCreated, c)
return
Expand Down

0 comments on commit 0442831

Please sign in to comment.