【问题标题】:How I can add users in Telegram channels using TLSharp?如何使用 TLSharp 在 Telegram 频道中添加用户?
【发布时间】:2020-05-06 14:56:39
【问题描述】:

我知道如何使用 TLSharp 创建一个新频道,但是如何将用户添加到该频道?

【问题讨论】:

    标签: android xamarin telegram


    【解决方案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】:

      将 SendRequestAsync 替换为 client.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;
          }
      

      【讨论】:

      • 如果我想邀请我的电报联系人,我应该怎么做?我的意思是我在哪里可以让用户成为 TLAbsInputUser?
      【解决方案3】:

      也许它会帮助某人

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-02-23
        • 2016-09-08
        • 2018-06-11
        • 2016-11-14
        • 2016-04-04
        • 1970-01-01
        • 2019-04-27
        相关资源
        最近更新 更多