Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 핸드폰 텔레그램으로 인증번호를 요청 합니다.
        /// </summary>
        /// <returns>hash code</returns>
        public async Task <string> SendCodeRequest()
        {
            //핸드폰 텔레그램으로 인증번호를 요청 합니다.
            var hash = await client.SendCodeRequestAsync(_phoneNumber);

            return(hash);
        }
Exemplo n.º 3
0
        protected async System.Threading.Tasks.Task SendCodeTelegram(string numeroTelefono)
        {
            var client = new TLSharp.Core.TelegramClient(106191, "2a5c0da8fcb3acfdf501c3f17fb0fa5f");
            await client.ConnectAsync();

            var hash = await client.SendCodeRequestAsync(numeroTelefono);
        }
Exemplo n.º 4
0
        public virtual async Task AuthUser()
        {
            var client = new TLSharp.Core.TelegramClient(apiId, apiHash);

            await client.ConnectAsync();

            phoneCodeHash = await client.SendCodeRequestAsync(PhoneNumber);
        }
Exemplo n.º 5
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);
        }