Add chat flood error

This commit is contained in:
Ali 2023-03-20 16:34:11 +04:00
parent f92f4c38c6
commit 16d5058cc7
3 changed files with 12 additions and 1 deletions

View File

@ -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.";

View File

@ -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") {

View File

@ -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))
}