首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能踢成员python telethon

不能踢成员python telethon
EN

Stack Overflow用户
提问于 2022-02-17 17:20:40
回答 1查看 431关注 0票数 0

嗨,我有一个问题,踢我的朋友从我的小组和频道。我想通过telethon将其从我的频道或组中删除。我有个问题:Telegram doesn’t actually have a request to kick a user from a group. Instead, you need to restrict them so they can’t see messages. Any date is enough:

https://arabic-telethon.readthedocs.io/en/latest/examples/chats-and-channels.html#kicking-a-member

我试着用这段代码

代码语言:javascript
复制
from telethon.sync import TelegramClient
from telethon.tl.functions.channels import EditBannedRequest
from telethon.tl.types import ChatBannedRights

client = TelegramClient(self.phone, self.api_id, self.api_hash)
client(EditBannedRequest("myChannelName", "myFriendUserName", ChatBannedRights(
        until_date=None,
        view_messages=True
)))

我得到了错误telethon.errors.rpcerrorlist.ChatWriteForbiddenError: You can't write in this chat (caused by EditBannedRequest)

如何通过电视或一些不同的方式将用户从电报组或频道中删除?

EN

回答 1

Stack Overflow用户

发布于 2022-02-17 21:13:27

你只能踢他们,但我不认为是这样的,因为“禁止人们”你应该这么做:

代码语言:javascript
复制
from datetime import timedelta
await client.edit_permissions(chat_entity, user_entity, view_messages=False)

正如文档中所说的

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71162660

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档