如何使用 Telethon(Telegram python 库)InviteToChannelRequest 将用户添加到组

How to add user to group using Telethon (Telegram python library) InviteToChannelRequest

我正在使用 Telegram 的 Telethon python 库,目前正在尝试使用以下方法将用户添加到我的群组:https://docs.telethon.dev/en/latest/examples/chats-and-channels.html#adding-someone-else-to-such-chat-or-channel

但是,我 运行 遇到了 InviteToChannelRequest 函数的问题,其签名如下:

channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates

如您所见,通道应该是 InputChannel 类型,但是当我尝试创建一个 InputChannel 以使用它的构造函数传递给函数时,如下所示:

inputChannel#afeb712e channel_id:int access_hash:long = InputChannel

我没有群组的 access_hash,所以我无法创建 InputChannel 以传递给 InviteToChannelRequest 函数。

那么我究竟如何获得我想添加用户的群组的 access_hash 或如何使用 InviteToChannelRequest 功能?

如果我尝试创建一个没有 access_hash 的 InputChannel,这是我得到的错误:

谢谢!

事实证明,我创建的组被设置为私有,所以我继续使用电报应用程序并将其设置为 public,然后我 运行 这个片段:

result = client(GetDialogsRequest(
             offset_date=last_date,
             offset_id=0,
             offset_peer=InputPeerEmpty(),
             limit=chunk_size,
             hash = 0
))

其中列出了我想要的频道的详细信息以及 access_hash