How I can add users in Telegram channels using TLSharp?

不想你离开。 提交于 2019-12-11 06:14:28

问题


I know how to create a new channel using TLSharp, but how I can add users to this channel?


回答1:


 var contacts = new TLVector<TLInputPhoneContact>();
            contacts.lists.Add(new TLInputPhoneContact { first_name = "xxx", last_name = "xxx", phone = "xxx" });
            var req = new TLRequestImportContacts()
            {
                contacts = contacts
            };
            var contact = client.SendRequestAsync<TLImportedContacts>(req).GetAwaiter().GetResult();



回答2:


replace SendRequestAsync with client.SendRequestAsync so :

public async Task<TLUpdates> InviteUserToChannel(TLAbsInputUser user, TLInputChannel channelid)
    {
        TLVector<TLAbsInputUser> u = new TLVector<TLAbsInputUser>();
        u.lists.Add(user);
        var req = new TLRequestInviteToChannel()
        {
            channel = channelid,
            users = u
        };
        var update = await client.SendRequestAsync<TLUpdates>(req);
        return update;
    }



回答3:


Maybe it will help someone

    public async Task<TLUpdates> InviteUserToChannel(TLAbsInputUser user, TLInputChannel channelid)
    {
        TLVector<TLAbsInputUser> u = new TLVector<TLAbsInputUser>();
        u.lists.Add(user);
        var req = new TLRequestInviteToChannel()
        {
            channel = channelid,
            users = u
        };
        TLUpdates update =  await SendRequestAsync<TLUpdates>(req);
        return update;
    }


来源:https://stackoverflow.com/questions/43610203/how-i-can-add-users-in-telegram-channels-using-tlsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!