[WIP] Stars [skip ci]

This commit is contained in:
Isaac
2025-06-24 00:16:00 +02:00
parent 9a14b076c6
commit 51a16c7110
10 changed files with 123 additions and 50 deletions

View File

@@ -258,38 +258,52 @@ public class ChatMessageActionBubbleContentNode: ChatMessageBubbleContentNode {
}
)).string
let amountString: String
var pricePart = ""
if let amount, amount.amount != .zero {
let amountString: String
switch amount.currency {
case .stars:
amountString = amount.amount.value == 1 ? "\(amount.amount) Star" : "\(amount.amount) Stars"
case .ton:
amountString = "\(amount.amount) TON"
amountString = "\(formatTonAmountText(amount.amount.value, dateTimeFormat: item.presentationData.dateTimeFormat)) TON"
}
switch amount.currency {
case .stars:
if !item.message.effectivelyIncoming(item.context.account.peerId) {
pricePart = "\n\n💰 The user have been charged \(amountString).\n\n⌛ **\(channelName)** will receive the Stars once the post has been live for 24 hours.\n\n🔄 If your remove the post before it has been live for 24 hours, the user's Stars will be refunded."
} else {
pricePart = "\n\n💰 You have been charged \(amountString).\n\n⌛ **\(channelName)** will receive your Stars once the post has been live for 24 hours.\n\n🔄 If **\(channelName)** removes the post before it has been live for 24 hours, your Stars will be refunded."
}
case .ton:
if !item.message.effectivelyIncoming(item.context.account.peerId) {
pricePart = "\n\n💰 The user have been charged \(amountString).\n\n⌛ **\(channelName)** will receive TON once the post has been live for 24 hours.\n\n🔄 If your remove the post before it has been live for 24 hours, the user's TON will be refunded."
} else {
pricePart = "\n\n💰 You have been charged \(amountString).\n\n⌛ **\(channelName)** will receive your TON once the post has been live for 24 hours.\n\n🔄 If **\(channelName)** removes the post before it has been live for 24 hours, your TON will be refunded."
}
}
} else {
amountString = "0 Stars"
}
let rawString: String
if let timestamp {
if Int32(Date().timeIntervalSince1970) >= timestamp {
if !item.message.effectivelyIncoming(item.context.account.peerId) {
rawString = "📅 The post has been automatically published in **\(channelName)** **\(timeString)**.\n\n💰 The user have been charged \(amountString).\n\n⌛ **\(channelName)** will receive the Stars once the post has been live for 24 hours.\n\n🔄 If your remove the post before it has been live for 24 hours, the user's Stars will be refunded."
rawString = "📅 The post has been automatically published in **\(channelName)** **\(timeString)**." + pricePart
} else {
rawString = "📅 Your post has been automatically published in **\(channelName)** **\(timeString)**.\n\n💰 You have been charged \(amountString).\n\n⌛ **\(channelName)** will receive your Stars once the post has been live for 24 hours.\n\n🔄 If **\(channelName)** removes the post before it has been live for 24 hours, your Stars will be refunded."
rawString = "📅 Your post has been automatically published in **\(channelName)** **\(timeString)**." + pricePart
}
} else {
if !item.message.effectivelyIncoming(item.context.account.peerId) {
rawString = "📅 The post will be automatically published in **\(channelName)** **\(timeString)**.\n\n💰 The user have been charged \(amountString).\n\n⌛ **\(channelName)** will receive the Stars once the post has been live for 24 hours.\n\n🔄 If your remove the post before it has been live for 24 hours, the user's Stars will be refunded."
rawString = "📅 The post will be automatically published in **\(channelName)** **\(timeString)**." + pricePart
} else {
rawString = "📅 Your post will be automatically published in **\(channelName)** **\(timeString)**.\n\n💰 You have been charged \(amountString).\n\n⌛ **\(channelName)** will receive your Stars once the post has been live for 24 hours.\n\n🔄 If **\(channelName)** removes the post before it has been live for 24 hours, your Stars will be refunded."
rawString = "📅 Your post will be automatically published in **\(channelName)** **\(timeString)**." + pricePart
}
}
} else {
if !item.message.effectivelyIncoming(item.context.account.peerId) {
rawString = "📅 The post has been automatically published in **\(channelName)**.\n\n💰 The user have been charged \(amountString).\n\n⌛ **\(channelName)** will receive the Stars once the post has been live for 24 hours.\n\n🔄 If your remove the post before it has been live for 24 hours, the user's Stars will be refunded."
rawString = "📅 The post has been automatically published in **\(channelName)**." + pricePart
} else {
rawString = "📅 Your post has been automatically published in **\(channelName)**.\n\n💰 You have been charged \(amountString).\n\n⌛ **\(channelName)** will receive your Stars once the post has been live for 24 hours.\n\n🔄 If **\(channelName)** removes the post before it has been live for 24 hours, your Stars will be refunded."
rawString = "📅 Your post has been automatically published in **\(channelName)**." + pricePart
}
}
updatedAttributedString = parseMarkdownIntoAttributedString(rawString, attributes: MarkdownAttributes(