Похожие чаты

File "/home/tgcleaning/TGCleaner/bot/helper/__init__.py", line 248, in kick_user

await self.client.kick_participant(entity=chat_id,
File "/home/tgcleaning/TGCleaner/virtualenv/lib/python3.11/site-packages/telethon/client/chats.py", line 1171, in kick_participant
resp = await self(functions.channels.EditBannedRequest(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tgcleaning/TGCleaner/virtualenv/lib/python3.11/site-packages/telethon/client/users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tgcleaning/TGCleaner/virtualenv/lib/python3.11/site-packages/telethon/client/users.py", line 87, in _call
result = await future
^^^^^^^^^^^^
telethon.errors.rpcerrorlist.ChatWriteForbiddenError: You can't write in this chat (caused by EditBannedRequest)
Why it raises ChatWriteForbiddenError when i'm trying to kick user?

14 ответов

39 просмотров

Debug it hard enough. start by confirming get_entity(chat_id).left isn't True

Are you the chat admin?

Kelevra- Автор вопроса
AH⁻64 Aᴘᴀᴄʜᴇ
Are you the chat admin?

ChatAdminRequiredError not raised

Kelevra
ChatAdminRequiredError not raised

Well, more fundamentally, non admins cannot ban, mute or restrict permissions of another user of the chat (provided they're both members of the chat). So even if no error is raised, you cannot do admin actions. But I guess that is likely not your issue. Right?

Kelevra- Автор вопроса

When i was not admin, it raised ChatAdminRequiredError, but not now

Kelevra
When i was not admin, it raised ChatAdminRequiredE...

Do you have permissions to ban users? Is this your own test chat with your own accounts or is it some group that you were promoted to admin in?

Kelevra- Автор вопроса
AH⁻64 Aᴘᴀᴄʜᴇ
Do you have permissions to ban users? Is this your...

Probably im not in chat, but should be there another exception?

Kelevra
Probably im not in chat, but should be there anoth...

Ok for me attempting to ban a user in a chat where I am not an admin gives the following error, I'll try the other thing too telethon.errors.rpcerrorlist.ChatAdminRequiredError: Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group (caused by EditBannedRequest)

Kelevra
Probably im not in chat, but should be there anoth...

Now I did it for a person in a chat where I am not even there, and I get the same error

⎞ .·. ⎝ ⎝
ChatAdminRequired applies to chats you have joined

So, Case 1: I and the other user is in the same chat. I am not an admin. I get the ChatAdminRequiredError. Case 2: I am not in the chat where the other user is. I am not an admin (obviously). I still get the ChatAdminRequiredError. How?

AH⁻64 Aᴘᴀᴄʜᴇ
So, Case 1: I and the other user is in the same ch...

pics or it didn't happen for the one you didn't join, print(get_entity(chat_id).left) followed by its error

⎞ .·. ⎝ ⎝
pics or it didn't happen for the one you didn't ...

AAAAH my bad. For case 2, I checked channel instead of the associated chat for that one. I got this error instead telethon.errors.rpcerrorlist.ChatWriteForbiddenError: You can't write in this chat (caused by EditBannedRequest)

Kelevra- Автор вопроса
AH⁻64 Aᴘᴀᴄʜᴇ
AAAAH my bad. For case 2, I checked channel instea...

And is it valid exception for this case? I think - no

Похожие вопросы

Обсуждают сегодня

а зачем этот вопрос для удаления из чата?
Mёdkinson Medvezhkin
63
using next image component with s3 image: "url" parameter is valid but upstream response is invalid code: <Image fill src={s...
Fasil
3
Эх кто-то пришел и весь праздник испортил :( You need complex FBX scene importing setup to change things on import? good luck with that. You need navigation and pathfinding? g...
Serg Gini
5
Friends, how can I find my Wazirx wallet address?
Silm Silm
31
Какого хера? /Sources/App/Modules/User/Models/UserLinkApple.swift:21:20: warning: stored property '_id' of 'Sendable'-conforming class 'UserLinkApple' is mutable @ID(...
Alexander Sherbakov
14
Всем привет! Подскажите. Я написал приложение на Delphi 10.2 Tokyo под Windows 10. И передо мной стал вопрос о том чтобы сделать это приложение кроссплатформенным (под Linux и...
Дмитрий Завгородний
24
How the price of ANVL is decided? The buying pressure comes just from staking which is very slow, while the selling pressure might be huge. What are the benefits for those who...
MJ Javvaji @muralijavvaji
13
My 7 year old daughter recognizes the Bitcoin symbol and knows it's currency. What are the top ,3-5 most basic important concepts to convey to a kid about BCH? I started with ...
Big Hair
24
How many Cashfusion server now?
Crypto life
22
Кто знает локации, где можно машину красиво отфоткать?
Lalalashechki Lalala
23
Карта сайта