Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BotAPI7.5 #700

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,28 @@ func (b *Bot) MyShortDescription(language string) (*BotInfo, error) {
return b.botInfo(language, "getMyShortDescription")
}

func (b *Bot) GetStarTransactions(offset, limit int) ([]StarTransaction, error) {
params := map[string]int{
"offset": offset,
"limit": limit,
}

data, err := b.Raw("getStarTransactions", params)
if err != nil {
return nil, err
}

var resp struct {
Result struct {
Transactions []StarTransaction `json:"transactions"`
}
}
if err := json.Unmarshal(data, &resp); err != nil {
return nil, wrapError(err)
}
return resp.Result.Transactions, nil
}

func (b *Bot) botInfo(language, key string) (*BotInfo, error) {
params := map[string]string{
"language_code": language,
Expand Down
4 changes: 4 additions & 0 deletions media.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ type Location struct {
// Period in seconds for which the location will be updated
// (see Live Locations, should be between 60 and 86400.)
LivePeriod int `json:"live_period,omitempty"`

// (Optional) Unique identifier of the business connection
// on behalf of which the message to be edited was sent
BusinessConnectionID string `json:"business_connection_id"`
}

// Venue object represents a venue location with name, address and
Expand Down
72 changes: 72 additions & 0 deletions stars.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package telebot

import "time"

type TransactionType = string

const (
TransactionTypeFragment TransactionType = "fragment"
TransactionTypeUser TransactionType = "user"
TransactionTypeOther TransactionType = "other"
TransactionPartnerTelegramAds TransactionType = "telegram_ads"
)

type RevenueState = string

const (
RevenueStatePending RevenueState = "pending"
RevenueStateSucceeded RevenueState = "succeeded"
RevenueStateFailed RevenueState = "failed"
)

type TransactionPartner struct {
// Type of the state
Type TransactionType `json:"type"`

// (Optional) State of the transaction if the transaction is outgoing$$
WithdrawalState RevenueWithdrawalState `json:"withdrawal_state,omitempty"`

// Information about the user
Partner *User `json:"user,omitempty"`

// (Optional) Bot-specified invoice payload
InvoicePayload string `json:"invoice_payload"`
}

type RevenueWithdrawalState struct {
// Type of the state
Type RevenueState `json:"type"`

// Date the withdrawal was completed in Unix time
Date int `json:"date,omitempty"`

// An HTTPS URL that can be used to see transaction details
URL string `json:"url,omitempty"`
}

type StarTransaction struct {
// Unique identifier of the transaction. Coincides with the identifer of the
// original transaction for refund transactions. Coincides with
// SuccessfulPayment.telegram_payment_charge_id for successful incoming
// payments from users.
ID string `json:"id"`

// Number of Telegram Stars transferred by the transaction
Amount int `json:"amount"`

// Date the transaction was created in Unix time
Unixtime int64 `json:"date"`

// (Optional) Source of an incoming transaction (e.g., a user purchasing goods
// or services, Fragment refunding a failed withdrawal). Only for incoming transactions
Source TransactionPartner `json:"source"`

// (Optional) Receiver of an outgoing transaction (e.g., a user for a purchase
// refund, Fragment for a withdrawal). Only for outgoing transactions
Receiver TransactionPartner `json:"receiver"`
}

// Date returns the local datetime.
func (c *StarTransaction) Date() time.Time {
return time.Unix(c.Unixtime, 0)
}
Loading