all repos — telegram-bot-api @ 523c355779e252fe0a55a4cf6ac6acfb4de1719e

Golang bindings for the Telegram Bot API

Merge pull request #26 from OvyFlash/bot-api-7.5

Bot API 7.5 implementation
OvyFlash 46941696+OvyFlash@users.noreply.github.com
Sun, 07 Jul 2024 00:50:35 +0300
commit

523c355779e252fe0a55a4cf6ac6acfb4de1719e

parent

90edbbc66acb285e5c3f0556cfc78241eba9f36e

4 files changed, 99 insertions(+), 3 deletions(-)

jump to
M configs.goconfigs.go

@@ -2035,6 +2035,27 @@

return params, nil } +// Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object. +type GetStarTransactionsConfig struct { + // Number of transactions to skip in the response + Offset int64 + // The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100. + Limit int64 +} + +func (config GetStarTransactionsConfig) method() string { + return "getStarTransactions" +} + +func (config GetStarTransactionsConfig) params() (Params, error) { + params := make(Params) + + params.AddNonZero64("offset", config.Offset) + params.AddNonZero64("limit", config.Limit) + + return params, nil +} + // RefundStarPaymentConfig refunds a successful payment in Telegram Stars. // Returns True on success. type RefundStarPaymentConfig struct {
M helper_structs.gohelper_structs.go

@@ -65,8 +65,9 @@

// BaseEdit is base type of all chat edits. type BaseEdit struct { BaseChatMessage - InlineMessageID string - ReplyMarkup *InlineKeyboardMarkup + InlineMessageID string + ReplyMarkup *InlineKeyboardMarkup + BusinessConnectionID string } func (edit BaseEdit) params() (Params, error) {

@@ -83,6 +84,7 @@ params.Merge(p1)

} err := params.AddInterface("reply_markup", edit.ReplyMarkup) + params.AddNonEmpty("business_connection_id", edit.BusinessConnectionID) return params, err }
M types.gotypes.go

@@ -2374,6 +2374,8 @@ type InlineKeyboardButton struct {

// Text label text on the button Text string `json:"text"` // URL HTTP or tg:// url to be opened when button is pressed. + // Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username, + // if this is allowed by their privacy settings. // // optional URL *string `json:"url,omitempty"`

@@ -2389,6 +2391,7 @@ CallbackData *string `json:"callback_data,omitempty"`

// WebApp is the Description of the Web App that will be launched when the user presses the button. // The Web App will be able to send an arbitrary message on behalf of the user using the method // answerWebAppQuery. Available only in private chats between a user and the bot. + // Not supported for messages sent on behalf of a Telegram Business account. // // optional WebApp *WebAppInfo `json:"web_app,omitempty"`

@@ -2401,6 +2404,7 @@ // in inline mode when they are currently in a private chat with it.

// Especially useful when combined with switch_pm… actions – in this case // the user will be automatically returned to the chat they switched from, // skipping the chat selection screen. + // Not supported for messages sent on behalf of a Telegram Business account. // // optional SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`

@@ -2410,12 +2414,14 @@ // Can be empty, in which case only the bot's username will be inserted.

// // This offers a quick way for the user to open your bot in inline mode // in the same chat – good for selecting something from multiple options. + // Not supported for messages sent on behalf of a Telegram Business account. // // optional SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` //SwitchInlineQueryChosenChat If set, pressing the button will prompt the user to //select one of their chats of the specified type, open that chat and insert the bot's - //username and the specified inline query in the input field + //username and the specified inline query in the input field. + // Not supported for messages sent on behalf of a Telegram Business account. // //optional SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"`

@@ -4889,3 +4895,69 @@ //

// optional OrderInfo *OrderInfo `json:"order_info,omitempty"` } + +// RevenueWithdrawalState describes the state of a revenue withdrawal operation. +// Currently, it can be one of +// - RevenueWithdrawalStatePending +// - RevenueWithdrawalStateSucceeded +// - RevenueWithdrawalStateFailed +type RevenueWithdrawalState struct { + // Type of the state. Must be one of: + // - pending + // - succeeded + // - failed + Type string `json:"type"` + // Date the withdrawal was completed in Unix time. Represents only in “succeeded” state + Date int64 `json:"date,omitempty"` + // An HTTPS URL that can be used to see transaction details. + // Represents only in “succeeded” state + URL string `json:"url,omitempty"` +} + +// TransactionPartner describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of +// - TransactionPartnerFragment +// - TransactionPartnerUser +// - TransactionPartnerOther +type TransactionPartner struct { + //Type of the transaction partner. Must be one of: + // - fragment + // - user + // - other + Type string `json:"type"` + // State of the transaction if the transaction is outgoing. + // Represent only in "fragment" state + // + // optional + WithdrawalState *RevenueWithdrawalState `json:"withdrawal_state,omitempty"` + // Information about the user. + // Represent only in "user" state + User *User `json:"user,omitempty"` +} + +// StarTransaction describes a Telegram Star transaction. +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 int64 `json:"amount"` + // Date the transaction was created in Unix time + Date int64 `json:"date"` + // Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). + // Only for incoming transactions + // + // optional + Source *TransactionPartner `json:"source,omitempty"` + // Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). + // Only for outgoing transactions + // + // optional + Reciever *TransactionPartner `json:"reciever,omitempty"` +} + +// StarTransactions contains a list of Telegram Star transactions. +type StarTransactions struct { + // The list of transactions + Transactions []StarTransaction `json:"transactions"` +}
M types_test.gotypes_test.go

@@ -376,6 +376,7 @@ _ Chattable = SetMyShortDescriptionConfig{}

_ Chattable = GetMyNameConfig{} _ Chattable = SetMyNameConfig{} _ Chattable = RefundStarPaymentConfig{} + _ Chattable = GetStarTransactionsConfig{} ) // Ensure all Fileable types are correct.