Skip to content

Commit

Permalink
Bot API 7.10
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed Sep 18, 2024
1 parent 571d678 commit 1be977a
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public struct TGCreateInvoiceLinkParams: Encodable {
/// Product description, 1-255 characters
public var description: String

/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
public var payload: String

/// Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct TGSendInvoiceParams: Encodable {
/// Product description, 1-255 characters
public var description: String

/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
public var payload: String

/// Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ public struct TGSendPaidMediaParams: Encodable {
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.
public var chatId: TGChatId

/// The number of Telegram Stars that must be paid to buy access to the media
/// The number of Telegram Stars that must be paid to buy access to the media; 1-2500
public var starCount: Int

/// A JSON-serialized array describing the media to be sent; up to 10 items
public var media: [TGInputPaidMedia]

/// Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
public var payload: String?

/// Media caption, 0-1024 characters after entities parsing
public var caption: String?

Expand Down Expand Up @@ -51,6 +54,7 @@ public struct TGSendPaidMediaParams: Encodable {
case chatId = "chat_id"
case starCount = "star_count"
case media = "media"
case payload = "payload"
case caption = "caption"
case parseMode = "parse_mode"
case captionEntities = "caption_entities"
Expand All @@ -61,11 +65,12 @@ public struct TGSendPaidMediaParams: Encodable {
case replyMarkup = "reply_markup"
}

public init(businessConnectionId: String? = nil, chatId: TGChatId, starCount: Int, media: [TGInputPaidMedia], caption: String? = nil, parseMode: TGParseMode? = nil, captionEntities: [TGMessageEntity]? = nil, showCaptionAboveMedia: Bool? = nil, disableNotification: Bool? = nil, protectContent: Bool? = nil, replyParameters: TGReplyParameters? = nil, replyMarkup: TGReplyMarkup? = nil) {
public init(businessConnectionId: String? = nil, chatId: TGChatId, starCount: Int, media: [TGInputPaidMedia], payload: String? = nil, caption: String? = nil, parseMode: TGParseMode? = nil, captionEntities: [TGMessageEntity]? = nil, showCaptionAboveMedia: Bool? = nil, disableNotification: Bool? = nil, protectContent: Bool? = nil, replyParameters: TGReplyParameters? = nil, replyMarkup: TGReplyMarkup? = nil) {
self.businessConnectionId = businessConnectionId
self.chatId = chatId
self.starCount = starCount
self.media = media
self.payload = payload
self.caption = caption
self.parseMode = parseMode
self.captionEntities = captionEntities
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Swift Telegram SDK - Telegram Bot Swift SDK.

/**
The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription.
The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways.
SeeAlso Telegram Bot API Reference:
[ChatBoostSourceGiveaway](https://core.telegram.org/bots/api#chatboostsourcegiveaway)
Expand All @@ -13,6 +13,7 @@ public final class TGChatBoostSourceGiveaway: Codable {
case source = "source"
case giveawayMessageId = "giveaway_message_id"
case user = "user"
case prizeStarCount = "prize_star_count"
case isUnclaimed = "is_unclaimed"
}

Expand All @@ -22,16 +23,20 @@ public final class TGChatBoostSourceGiveaway: Codable {
/// Identifier of a message in the chat with the giveaway; the message could have been deleted already. May be 0 if the message isn't sent yet.
public var giveawayMessageId: Int

/// Optional. User that won the prize in the giveaway if any
/// Optional. User that won the prize in the giveaway if any; for Telegram Premium giveaways only
public var user: TGUser?

/// Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
public var prizeStarCount: Int?

/// Optional. True, if the giveaway was completed, but there was no user to win the prize
public var isUnclaimed: Bool?

public init (source: String, giveawayMessageId: Int, user: TGUser? = nil, isUnclaimed: Bool? = nil) {
public init (source: String, giveawayMessageId: Int, user: TGUser? = nil, prizeStarCount: Int? = nil, isUnclaimed: Bool? = nil) {
self.source = source
self.giveawayMessageId = giveawayMessageId
self.user = user
self.prizeStarCount = prizeStarCount
self.isUnclaimed = isUnclaimed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public final class TGChatInviteLink: Codable {
case expireDate = "expire_date"
case memberLimit = "member_limit"
case pendingJoinRequestCount = "pending_join_request_count"
case subscriptionPeriod = "subscription_period"
case subscriptionPrice = "subscription_price"
}

/// The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”.
Expand Down Expand Up @@ -48,7 +50,13 @@ public final class TGChatInviteLink: Codable {
/// Optional. Number of pending join requests created using this link
public var pendingJoinRequestCount: Int?

public init (inviteLink: String, creator: TGUser, createsJoinRequest: Bool, isPrimary: Bool, isRevoked: Bool, name: String? = nil, expireDate: Int? = nil, memberLimit: Int? = nil, pendingJoinRequestCount: Int? = nil) {
/// Optional. The number of seconds the subscription will be active for before the next payment
public var subscriptionPeriod: Int?

/// Optional. The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link
public var subscriptionPrice: Int?

public init (inviteLink: String, creator: TGUser, createsJoinRequest: Bool, isPrimary: Bool, isRevoked: Bool, name: String? = nil, expireDate: Int? = nil, memberLimit: Int? = nil, pendingJoinRequestCount: Int? = nil, subscriptionPeriod: Int? = nil, subscriptionPrice: Int? = nil) {
self.inviteLink = inviteLink
self.creator = creator
self.createsJoinRequest = createsJoinRequest
Expand All @@ -58,5 +66,7 @@ public final class TGChatInviteLink: Codable {
self.expireDate = expireDate
self.memberLimit = memberLimit
self.pendingJoinRequestCount = pendingJoinRequestCount
self.subscriptionPeriod = subscriptionPeriod
self.subscriptionPrice = subscriptionPrice
}
}
9 changes: 7 additions & 2 deletions Sources/SwiftTelegramSdk/Bot/Telegram/Models/TGGiveaway.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public final class TGGiveaway: Codable {
case hasPublicWinners = "has_public_winners"
case prizeDescription = "prize_description"
case countryCodes = "country_codes"
case prizeStarCount = "prize_star_count"
case premiumSubscriptionMonthCount = "premium_subscription_month_count"
}

Expand All @@ -41,17 +42,21 @@ public final class TGGiveaway: Codable {
/// Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
public var countryCodes: [String]?

/// Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for
/// Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
public var prizeStarCount: Int?

/// Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
public var premiumSubscriptionMonthCount: Int?

public init (chats: [TGChat], winnersSelectionDate: Int, winnerCount: Int, onlyNewMembers: Bool? = nil, hasPublicWinners: Bool? = nil, prizeDescription: String? = nil, countryCodes: [String]? = nil, premiumSubscriptionMonthCount: Int? = nil) {
public init (chats: [TGChat], winnersSelectionDate: Int, winnerCount: Int, onlyNewMembers: Bool? = nil, hasPublicWinners: Bool? = nil, prizeDescription: String? = nil, countryCodes: [String]? = nil, prizeStarCount: Int? = nil, premiumSubscriptionMonthCount: Int? = nil) {
self.chats = chats
self.winnersSelectionDate = winnersSelectionDate
self.winnerCount = winnerCount
self.onlyNewMembers = onlyNewMembers
self.hasPublicWinners = hasPublicWinners
self.prizeDescription = prizeDescription
self.countryCodes = countryCodes
self.prizeStarCount = prizeStarCount
self.premiumSubscriptionMonthCount = premiumSubscriptionMonthCount
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public final class TGGiveawayCompleted: Codable {
case winnerCount = "winner_count"
case unclaimedPrizeCount = "unclaimed_prize_count"
case giveawayMessage = "giveaway_message"
case isStarGiveaway = "is_star_giveaway"
}

/// Number of winners in the giveaway
Expand All @@ -24,9 +25,13 @@ public final class TGGiveawayCompleted: Codable {
/// Optional. Message with the giveaway that was completed, if it wasn't deleted
public var giveawayMessage: TGMessage?

public init (winnerCount: Int, unclaimedPrizeCount: Int? = nil, giveawayMessage: TGMessage? = nil) {
/// Optional. True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.
public var isStarGiveaway: Bool?

public init (winnerCount: Int, unclaimedPrizeCount: Int? = nil, giveawayMessage: TGMessage? = nil, isStarGiveaway: Bool? = nil) {
self.winnerCount = winnerCount
self.unclaimedPrizeCount = unclaimedPrizeCount
self.giveawayMessage = giveawayMessage
self.isStarGiveaway = isStarGiveaway
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// Swift Telegram SDK - Telegram Bot Swift SDK.

/**
This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.
This object represents a service message about the creation of a scheduled giveaway.
SeeAlso Telegram Bot API Reference:
[GiveawayCreated](https://core.telegram.org/bots/api#giveawaycreated)
**/
public final class TGGiveawayCreated: Codable {

/// Custom keys for coding/decoding `GiveawayCreated` struct
public enum CodingKeys: String, CodingKey {
case prizeStarCount = "prize_star_count"
}

/// Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
public var prizeStarCount: Int?

public init (prizeStarCount: Int? = nil) {
self.prizeStarCount = prizeStarCount
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public final class TGGiveawayWinners: Codable {
case winnerCount = "winner_count"
case winners = "winners"
case additionalChatCount = "additional_chat_count"
case prizeStarCount = "prize_star_count"
case premiumSubscriptionMonthCount = "premium_subscription_month_count"
case unclaimedPrizeCount = "unclaimed_prize_count"
case onlyNewMembers = "only_new_members"
Expand All @@ -41,7 +42,10 @@ public final class TGGiveawayWinners: Codable {
/// Optional. The number of other chats the user had to join in order to be eligible for the giveaway
public var additionalChatCount: Int?

/// Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for
/// Optional. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only
public var prizeStarCount: Int?

/// Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
public var premiumSubscriptionMonthCount: Int?

/// Optional. Number of undistributed prizes
Expand All @@ -56,13 +60,14 @@ public final class TGGiveawayWinners: Codable {
/// Optional. Description of additional giveaway prize
public var prizeDescription: String?

public init (chat: TGChat, giveawayMessageId: Int, winnersSelectionDate: Int, winnerCount: Int, winners: [TGUser], additionalChatCount: Int? = nil, premiumSubscriptionMonthCount: Int? = nil, unclaimedPrizeCount: Int? = nil, onlyNewMembers: Bool? = nil, wasRefunded: Bool? = nil, prizeDescription: String? = nil) {
public init (chat: TGChat, giveawayMessageId: Int, winnersSelectionDate: Int, winnerCount: Int, winners: [TGUser], additionalChatCount: Int? = nil, prizeStarCount: Int? = nil, premiumSubscriptionMonthCount: Int? = nil, unclaimedPrizeCount: Int? = nil, onlyNewMembers: Bool? = nil, wasRefunded: Bool? = nil, prizeDescription: String? = nil) {
self.chat = chat
self.giveawayMessageId = giveawayMessageId
self.winnersSelectionDate = winnersSelectionDate
self.winnerCount = winnerCount
self.winners = winners
self.additionalChatCount = additionalChatCount
self.prizeStarCount = prizeStarCount
self.premiumSubscriptionMonthCount = premiumSubscriptionMonthCount
self.unclaimedPrizeCount = unclaimedPrizeCount
self.onlyNewMembers = onlyNewMembers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class TGInputInvoiceMessageContent: Codable {
/// Product description, 1-255 characters
public var description: String

/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
public var payload: String

/// Optional. Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Swift Telegram SDK - Telegram Bot Swift SDK.

/**
This object contains information about a paid media purchase.
SeeAlso Telegram Bot API Reference:
[PaidMediaPurchased](https://core.telegram.org/bots/api#paidmediapurchased)
**/
public final class TGPaidMediaPurchased: Codable {

/// Custom keys for coding/decoding `PaidMediaPurchased` struct
public enum CodingKeys: String, CodingKey {
case from = "from"
case paidMediaPayload = "paid_media_payload"
}

/// User who purchased the media
public var from: TGUser

/// Bot-specified paid media payload
public var paidMediaPayload: String

public init (from: TGUser, paidMediaPayload: String) {
self.from = from
self.paidMediaPayload = paidMediaPayload
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public final class TGTransactionPartnerUser: Codable {
case user = "user"
case invoicePayload = "invoice_payload"
case paidMedia = "paid_media"
case paidMediaPayload = "paid_media_payload"
}

/// Type of the transaction partner, always “user”
Expand All @@ -28,10 +29,14 @@ public final class TGTransactionPartnerUser: Codable {
/// Optional. Information about the paid media bought by the user
public var paidMedia: [TGPaidMedia]?

public init (type: TGTransactionPartnerUserType, user: TGUser, invoicePayload: String? = nil, paidMedia: [TGPaidMedia]? = nil) {
/// Optional. Bot-specified paid media payload
public var paidMediaPayload: String?

public init (type: TGTransactionPartnerUserType, user: TGUser, invoicePayload: String? = nil, paidMedia: [TGPaidMedia]? = nil, paidMediaPayload: String? = nil) {
self.type = type
self.user = user
self.invoicePayload = invoicePayload
self.paidMedia = paidMedia
self.paidMediaPayload = paidMediaPayload
}
}
Loading

0 comments on commit 1be977a

Please sign in to comment.