diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 39413c8dc6..926bff5fc8 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -9081,3 +9081,6 @@ Sorry for the inconvenience."; "CreateGroup.PeersTitleDelimeter" = ", "; "CreateGroup.PeersTitleLastDelimeter" = " and "; + +"Conversation.SendMessageErrorTooFastTitle" = "Not so fast"; +"Conversation.SendMessageErrorTooFast" = "You are sending messages too fast. Please wait a bit."; diff --git a/submodules/TelegramCore/Sources/State/PendingMessageManager.swift b/submodules/TelegramCore/Sources/State/PendingMessageManager.swift index f66ef7a482..efbebd2ee3 100644 --- a/submodules/TelegramCore/Sources/State/PendingMessageManager.swift +++ b/submodules/TelegramCore/Sources/State/PendingMessageManager.swift @@ -57,11 +57,14 @@ public enum PendingMessageFailureReason { case slowmodeActive case tooMuchScheduled case voiceMessagesForbidden + case sendingTooFast } private func reasonForError(_ error: String) -> PendingMessageFailureReason? { if error.hasPrefix("PEER_FLOOD") { return .flood + } else if error.hasPrefix("SENDING_TOO_FAST") { + return .sendingTooFast } else if error.hasPrefix("USER_BANNED_IN_CHANNEL") { return .publicBan } else if error.hasPrefix("CHAT_SEND_") && error.hasSuffix("_FORBIDDEN") { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index e43f4c0993..0003bcb3d3 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -10555,11 +10555,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G |> deliverOnMainQueue).start(next: { [weak self] reason in if let strongSelf = self, strongSelf.currentFailedMessagesAlertController == nil { let text: String + var title: String? let moreInfo: Bool switch reason { case .flood: text = strongSelf.presentationData.strings.Conversation_SendMessageErrorFlood moreInfo = true + case .sendingTooFast: + text = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFast + title = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFastTitle + moreInfo = false case .publicBan: text = strongSelf.presentationData.strings.Conversation_SendMessageErrorGroupRestricted moreInfo = true @@ -10584,7 +10589,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})] } - let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: nil, text: text, actions: actions) + let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: title, text: text, actions: actions) strongSelf.currentFailedMessagesAlertController = controller strongSelf.present(controller, in: .window(.root)) }