Exemple #1
0
        /// <summary>
        /// 인증 요청 처리를 한다.
        /// </summary>
        /// <param name="hash">인증 요청(SendCodeRequest) 시 생성된 코드</param>
        /// <param name="code">핸드폰 텔래그램으로 받은 코드</param>
        /// <returns></returns>
        public async Task <TLUser> MakeAuthAsync(string hash, string code)
        {
            //인증을 요청한다.
            var user = await client.MakeAuthAsync(_phoneNumber, hash, code);

            return(user);
        }
Exemple #2
0
        public virtual async Task MakeAuthAsync(string code)
        {
            var client = new TLSharp.Core.TelegramClient(apiId, apiHash);
            await client.ConnectAsync();

            var user = await client.MakeAuthAsync(PhoneNumber, phoneCodeHash, code);
        }
Exemple #3
0
        protected async System.Threading.Tasks.Task SendMessaggioTelegram(string numeroTelefono, string code, string messaggio)
        {
            var client = new TLSharp.Core.TelegramClient(106191, "2a5c0da8fcb3acfdf501c3f17fb0fa5f");
            await client.ConnectAsync();

            var hash = await client.SendCodeRequestAsync(numeroTelefono);

            var user = await client.MakeAuthAsync(numeroTelefono, hash, code);

            //get available contacts
            var result = await client.GetContactsAsync();

            //find recipient in contacts
            var customer = result.Users
                           .Where(x => x.GetType() == typeof(TeleSharp.TL.TLUser))
                           .Cast <TeleSharp.TL.TLUser>()
                           .FirstOrDefault(x => x.Phone == numeroTelefono);

            /*if (user.ToList().Count != 0)
             * {
             *  foreach (var u in user)
             *  {
             *      if (u.phone.Contains("3965604"))
             *      {
             *          //send message
             *          await client.SendMessageAsync(new TLInputPeerUser() { user_id = u.id }, textBox3.Text);
             *      }
             *  }
             * }*/
            // @channelname or chat_id, messaggio da inviare
            await client.SendMessageAsync(new TeleSharp.TL.TLInputPeerUser()
            {
                UserId = customer.Id
            }, messaggio);
        }
Exemple #4
0
        private async void Auth(TLSharp.Core.TelegramClient client, string PhoneNumber)
        {
            if (client.IsUserAuthorized())
            {
                return;
            }

            //인증-한번 받으면 된다
            var hash = await client.SendCodeRequestAsync(PhoneNumber);

            var code = "20948";             // you can change code in debugger
            var user = await client.MakeAuthAsync(PhoneNumber, hash, code);
        }