AddPeerMember: added new bot-related errors

This commit is contained in:
Ilya Laktyushin 2019-07-10 03:50:50 +02:00
parent 5675e81f8b
commit 742886534a
5 changed files with 2530 additions and 2515 deletions

View File

@ -4468,3 +4468,6 @@ Any member of this group will be able to see messages in the channel.";
"Appearance.TintAllColors" = "Tint All Colors";
"Contacts.DeselectAll" = "Deselect All";
"Channel.TooMuchBots" = "Sorry, there are already too many bots in this group. Please remove some of the bots you're not using first.";
"Channel.BotDoesntSupportGroups" = "Sorry, this bot is telling us it doesn't want to be added to groups. You can't add this bot unless its developers change their mind.";

View File

@ -77,6 +77,8 @@ public enum AddChannelMemberError {
case limitExceeded
case tooMuchJoined
case bot(PeerId)
case botDoesntSupportGroups
case tooMuchBots
}
public func addChannelMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), AddChannelMemberError> {
@ -106,6 +108,10 @@ public func addChannelMember(account: Account, peerId: PeerId, memberId: PeerId)
return .fail(.restricted)
case "USER_BOT":
return .fail(.bot(memberId))
case "BOT_GROUPS_BLOCKED":
return .fail(.botDoesntSupportGroups)
case "BOTS_TOO_MUCH":
return .fail(.tooMuchBots)
default:
return .fail(.generic)
}

View File

@ -409,6 +409,10 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) ->
contactsController?.dismiss()
})
return
case .botDoesntSupportGroups:
text = presentationData.strings.Channel_BotDoesntSupportGroups
case .tooMuchBots:
text = presentationData.strings.Channel_TooMuchBots
}
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
contactsController?.dismiss()