Improve permission-related errors (#1231)

This commit is contained in:
painor 2019-07-10 22:19:50 +01:00 committed by Lonami
parent 2adc746143
commit ae1c1b3912
2 changed files with 8 additions and 2 deletions

View File

@ -847,6 +847,9 @@ class ChatMethods:
"""
entity = await self.get_input_entity(entity)
user = await self.get_input_entity(user)
if isinstance(user, types.InputPeerSelf):
raise ValueError('You cannot admin yourself')
if not isinstance(user, types.InputPeerUser):
raise ValueError('You must pass a user entity')
@ -996,6 +999,9 @@ class ChatMethods:
))
user = await self.get_input_entity(user)
if isinstance(user, types.InputPeerSelf):
raise ValueError('You cannot restrict yourself')
if not isinstance(user, types.InputPeerUser):
raise ValueError('You must pass a user entity')

View File

@ -207,7 +207,7 @@ REPLY_MARKUP_TOO_LONG,400,The data embedded in the reply markup buttons was too
RESULT_ID_DUPLICATE,400,Duplicated IDs on the sent results. Make sure to use unique IDs.
RESULT_TYPE_INVALID,400,Result type invalid
RESULTS_TOO_MUCH,400,You sent too many results. See https://core.telegram.org/bots/api#answerinlinequery for the current limit.
RIGHT_FORBIDDEN,403,Your admin rights do not allow you to do this
RIGHT_FORBIDDEN,403,Either your admin rights do not allow you to do this or you passed the wrong rights combination (some rights only apply to channels and vice versa)
RPC_CALL_FAIL,,"Telegram is having internal issues, please try again later."
RPC_MCGET_FAIL,,"Telegram is having internal issues, please try again later."
RSA_DECRYPT_FAILED,400,Internal RSA decryption failed
@ -249,7 +249,7 @@ USERNAME_NOT_OCCUPIED,400,The username is not in use by anyone else yet
USERNAME_OCCUPIED,400,The username is already taken
USERS_TOO_FEW,400,"Not enough users (to create a chat, for example)"
USERS_TOO_MUCH,400,"The maximum number of users has been exceeded (to create a chat, for example)"
USER_ADMIN_INVALID,400,You're not an admin
USER_ADMIN_INVALID,400,Either you're not an admin or you tried to ban an admin that you didn't promote
USER_ALREADY_PARTICIPANT,400,The authenticated user is already a participant of the chat
USER_BANNED_IN_CHANNEL,400,You're banned from sending messages in supergroups/channels
USER_BLOCKED,400,User blocked

1 name codes description
207 RESULT_ID_DUPLICATE 400 Duplicated IDs on the sent results. Make sure to use unique IDs.
208 RESULT_TYPE_INVALID 400 Result type invalid
209 RESULTS_TOO_MUCH 400 You sent too many results. See https://core.telegram.org/bots/api#answerinlinequery for the current limit.
210 RIGHT_FORBIDDEN 403 Your admin rights do not allow you to do this Either your admin rights do not allow you to do this or you passed the wrong rights combination (some rights only apply to channels and vice versa)
211 RPC_CALL_FAIL Telegram is having internal issues, please try again later.
212 RPC_MCGET_FAIL Telegram is having internal issues, please try again later.
213 RSA_DECRYPT_FAILED 400 Internal RSA decryption failed
249 USERNAME_OCCUPIED 400 The username is already taken
250 USERS_TOO_FEW 400 Not enough users (to create a chat, for example)
251 USERS_TOO_MUCH 400 The maximum number of users has been exceeded (to create a chat, for example)
252 USER_ADMIN_INVALID 400 You're not an admin Either you're not an admin or you tried to ban an admin that you didn't promote
253 USER_ALREADY_PARTICIPANT 400 The authenticated user is already a participant of the chat
254 USER_BANNED_IN_CHANNEL 400 You're banned from sending messages in supergroups/channels
255 USER_BLOCKED 400 User blocked