如何使用TLSharp在Telegram频道中添加用户?

时间:2017-04-25 12:05:59

标签: android xamarin telegram

我知道如何使用TLSharp创建新频道,但我如何才能将用户添加到此频道?

3 个答案:

答案 0 :(得分: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();

答案 1 :(得分:1)

用client.SendRequestAsync替换SendRequestAsync,所以:

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;
    }

答案 2 :(得分:0)

也许它会帮助某人

    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;
    }