You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用WTelegramClient将公开群组/超级群组转为私有?

使用WTelegramClient将公开群组/超级群组转为私有

针对超级群组(Supergroup)

超级群组的公开状态由公开用户名、邀请链接控制,执行以下两步即可转为私有:

  1. 移除公开用户名:调用Channels_EditUsername方法,传入超级群组ID和空字符串作为新用户名
    // 替换为你的超级群组ID和access_hash
    var inputChannel = new InputChannel(supergroupId, supergroupAccessHash);
    await client.Channels_EditUsername(inputChannel, "");
    
  2. 关闭公开邀请链接:调用Channels_ToggleInvite方法,关闭公开邀请权限
    await client.Channels_ToggleInvite(inputChannel, false);
    

(可选)若需彻底屏蔽搜索可发现性,可移除群组头像或修改简介说明状态。

针对普通群组(Group)

普通群组转为私有需限制成员邀请权限、移除公开链接:

  1. 设置仅管理员可邀请成员:调用Messages_EditChatDefaultBannedRights,禁止普通用户发起邀请
    // 替换为你的普通群组ID
    var inputPeer = new InputPeerChat(groupId);
    await client.Messages_EditChatDefaultBannedRights(inputPeer, new ChatBannedRights
    {
        until_date = 0,
        invite_users = true // 禁止普通用户邀请他人,仅管理员可操作
    });
    
  2. 删除所有公开邀请链接:先调用Messages_GetExportedChatInvites获取所有链接,再逐个调用Messages_DeleteExportedChatInvite删除
    var invites = await client.Messages_GetExportedChatInvites(inputPeer, false);
    foreach (var invite in invites)
        if (invite is ExportedChatInvite exported)
            await client.Messages_DeleteExportedChatInvite(inputPeer, exported.link);
    

注意事项

  • 操作账号必须是群组管理员,且拥有change_info、invite_users权限
  • 超级群组的access_hash可通过client.GetChatAsync(supergroupId)获取群组信息后提取
  • 建议先用测试群组验证操作,避免影响正式群组

内容的提问来源于stack exchange,提问作者Yahya Al-Nuaimi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 00:45:46