【问题标题】:How can I transfer members of a Telegram channel to another Telegram channel如何将 Telegram 频道的成员转移到另一个 Telegram 频道
【发布时间】:2023-12-29 22:32:01
【问题描述】:

如何将 Telegram 频道(我是他们的管理员)或群组(或超级群组)的成员转移到另一个 Telegram 频道或群组(我不是他们的管理员)? 问候

【问题讨论】:

    标签: bots telegram channel


    【解决方案1】:

    您可以非常轻松地使用 Telethon,并且您有很多文档。

    针对你的具体问题

    from telethon.tl.functions.channels import InviteToChannelRequest
    
    client(InviteToChannelRequest(
    channel=SomeChannelId, 
    users = ['SomeUserName']
    ))
    

    【讨论】:

      【解决方案2】:

      我用过电视马拉松:

      from telethon import TelegramClient
      from telethon.tl.functions.channels import InviteToChannelRequest
      from telethon.tl.functions.channels import GetParticipantsRequest
      import asyncio
      
      # Use your own values from my.telegram.org
      api_id = 12345
      api_hash = 'a1a1a1a1a1a1a11'
      
      channel_to_name = 'migrate_to'
      channel_from_name = 'migrate_from'
      loop = asyncio.get_event_loop()
      
      
      client = TelegramClient('anon', api_id, api_hash)
      loop.run_until_complete(client.connect())
      channel_from = loop.run_until_complete(client.get_entity(channel_from_name))
      channel_to = loop.run_until_complete(client.get_entity(channel_to_name))
      users = client.iter_participants(channel_from)
      users_arr = []
      for user in users:
          users_arr.append(user)
      loop.run_until_complete(client(InviteToChannelRequest(
              channel_to,
              users_arr
          )))
      

      【讨论】:

        最近更新 更多