コード例 #1
0
ファイル: TelegramClient.cs プロジェクト: rdavoudi/TelegramWS
        public async Task <int?> ImportContact(string phone, string first_name, string last_name)
        {
            var input_contact = new TLInputPhoneContact()
            {
                Phone     = phone,
                FirstName = first_name,
                LastName  = last_name,
                ClientId  = 0
            };

            List <TLInputPhoneContact> lst = new List <TLInputPhoneContact>();

            lst.Add(input_contact);

            var request = new TLRequestImportContacts()
            {
                Contacts = new TLVector <TLInputPhoneContact>()
                {
                    lists = lst
                }
            };
            await _sender.Send(request);

            await _sender.Receive(request);

            var importedUser = request.Response.Imported.FirstOrDefault();

            return(importedUser?.UserId);
        }
コード例 #2
0
        private async void SendExecute()
        {
            var contact = new TLInputPhoneContact
            {
                ClientId  = GetHashCode(),
                FirstName = FirstName,
                LastName  = LastName,
                Phone     = "+" + PhoneCode + PhoneNumber
            };

            var response = await ProtoService.ImportContactsAsync(new TLVector <TLInputContactBase> {
                contact
            });

            if (response.IsSucceeded)
            {
                if (response.Result.Users.Count > 0)
                {
                    Aggregator.Publish(new TLUpdateContactLink
                    {
                        UserId      = response.Result.Users[0].Id,
                        MyLink      = new TLContactLinkContact(),
                        ForeignLink = new TLContactLinkUnknown()
                    });
                }
                else
                {
                    await TLMessageDialog.ShowAsync(Strings.Android.ContactNotRegistered, Strings.Android.AppName, Strings.Android.Invite, Strings.Android.Cancel);
                }
            }
            else
            {
                await TLMessageDialog.ShowAsync(Strings.Android.ContactNotRegistered, Strings.Android.AppName, Strings.Android.Invite, Strings.Android.Cancel);
            }
        }
コード例 #3
0
        private async void AddExecute()
        {
            var user = _item as TLUser;

            if (user == null)
            {
                return;
            }

            var confirm = await EditUserNameView.Current.ShowAsync(user.FirstName, user.LastName);

            if (confirm == ContentDialogResult.Primary)
            {
                var contact = new TLInputPhoneContact
                {
                    ClientId  = _item.Id,
                    FirstName = EditUserNameView.Current.FirstName,
                    LastName  = EditUserNameView.Current.LastName,
                    Phone     = _item.Phone
                };

                var response = await ProtoService.ImportContactsAsync(new TLVector <TLInputContactBase> {
                    contact
                });

                if (response.IsSucceeded)
                {
                    if (response.Result.Users.Count > 0)
                    {
                        Aggregator.Publish(new TLUpdateContactLink
                        {
                            UserId      = response.Result.Users[0].Id,
                            MyLink      = new TLContactLinkContact(),
                            ForeignLink = new TLContactLinkUnknown()
                        });
                    }

                    user.RaisePropertyChanged(() => user.HasFirstName);
                    user.RaisePropertyChanged(() => user.HasLastName);
                    user.RaisePropertyChanged(() => user.FirstName);
                    user.RaisePropertyChanged(() => user.LastName);
                    user.RaisePropertyChanged(() => user.FullName);
                    user.RaisePropertyChanged(() => user.DisplayName);

                    user.RaisePropertyChanged(() => user.HasPhone);
                    user.RaisePropertyChanged(() => user.Phone);

                    RaisePropertyChanged(() => IsEditEnabled);
                    RaisePropertyChanged(() => IsAddEnabled);

                    var dialog = CacheService.GetDialog(_item.ToPeer());
                    if (dialog != null)
                    {
                        dialog.RaisePropertyChanged(() => dialog.With);
                    }
                }
            }
        }
コード例 #4
0
        private async void enviarMensaje()
        {
            User u = new User();

            u.recoverUser(id);
            if (MainWindow.client.IsUserAuthorized())
            {
                var result = await MainWindow.client.GetContactsAsync();

                var user = result.Users
                           .Where(x => x.GetType() == typeof(TLUser))
                           .Cast <TLUser>()
                           .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                bool enviar = true;
                if (user == null)
                {
                    var phoneContact = new TLInputPhoneContact()
                    {
                        Phone = "34" + u.Telefono, FirstName = u.Nombre, LastName = u.Apellidos
                    };
                    var contacts = new List <TLInputPhoneContact>()
                    {
                        phoneContact
                    };
                    var req = new TLRequestImportContacts()
                    {
                        Contacts = new TLVector <TLInputPhoneContact>(contacts)
                    };
                    var rrr = await MainWindow.client.SendRequestAsync <TLImportedContacts>(req);

                    if (rrr.Imported.Count == 1)
                    {
                        user = result.Users
                               .Where(x => x.GetType() == typeof(TLUser))
                               .Cast <TLUser>()
                               .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                    }
                    else
                    {
                        enviar = false;
                    }
                }
                if (enviar && user != null)
                {
                    StringBuilder mensaje = new StringBuilder();
                    mensaje.Append(Strings.TelegramServiciosModificado + " \n");
                    DataTable servicios = us.datosMensaje(u.Iduser);
                    foreach (DataRow dr in servicios.Rows)
                    {
                        mensaje.Append(" - " + dr["nombre"] + ", " + diasSemana(dr["dias"].ToString()) + ", " + dr["turno"] + "\n");
                    }
                    await MainWindow.client.SendMessageAsync(new TLInputPeerUser()
                    {
                        UserId = user.Id
                    }, mensaje.ToString());
                }
            }
        }
コード例 #5
0
ファイル: MensajeUser.xaml.cs プロジェクト: teci98/TelERP
        private async void enviarMensaje()
        {
            User u = new User();

            u.recoverUser(id);
            if (MainWindow.client.IsUserAuthorized())
            {
                var result = await MainWindow.client.GetContactsAsync();

                var user = result.Users
                           .Where(x => x.GetType() == typeof(TLUser))
                           .Cast <TLUser>()
                           .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                bool enviar = true;
                if (user == null)
                {
                    var phoneContact = new TLInputPhoneContact()
                    {
                        Phone = "34" + u.Telefono, FirstName = u.Nombre, LastName = u.Apellidos
                    };
                    var contacts = new List <TLInputPhoneContact>()
                    {
                        phoneContact
                    };
                    var req = new TLRequestImportContacts()
                    {
                        Contacts = new TLVector <TLInputPhoneContact>(contacts)
                    };
                    var rrr = await MainWindow.client.SendRequestAsync <TLImportedContacts>(req);

                    if (rrr.Imported.Count == 1)
                    {
                        user = result.Users
                               .Where(x => x.GetType() == typeof(TLUser))
                               .Cast <TLUser>()
                               .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                    }
                    else
                    {
                        enviar = false;
                    }
                }
                if (enviar && user != null)
                {
                    await MainWindow.client.SendMessageAsync(new TLInputPeerUser()
                    {
                        UserId = user.Id
                    }, texto.Text);

                    CustomMessageBox.Show(Strings.MensajeEnviado);
                }
                else
                {
                    CustomMessageBox.Show(Strings.MsgNoTelegram);
                }
            }
        }
コード例 #6
0
ファイル: NewModAssign.xaml.cs プロジェクト: teci98/TelERP
        private async void enviarMensaje()
        {
            User u = new User();

            u.recoverUser(iduser);
            if (MainWindow.client.IsUserAuthorized())
            {
                var result = await MainWindow.client.GetContactsAsync();

                var user = result.Users
                           .Where(x => x.GetType() == typeof(TLUser))
                           .Cast <TLUser>()
                           .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                bool enviar = true;
                if (user == null)
                {
                    var phoneContact = new TLInputPhoneContact()
                    {
                        Phone = "34" + u.Telefono, FirstName = u.Nombre, LastName = u.Apellidos
                    };
                    var contacts = new List <TLInputPhoneContact>()
                    {
                        phoneContact
                    };
                    var req = new TLRequestImportContacts()
                    {
                        Contacts = new TLVector <TLInputPhoneContact>(contacts)
                    };
                    var rrr = await MainWindow.client.SendRequestAsync <TLImportedContacts>(req);

                    if (rrr.Imported.Count == 1)
                    {
                        user = result.Users
                               .Where(x => x.GetType() == typeof(TLUser))
                               .Cast <TLUser>()
                               .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                    }
                    else
                    {
                        enviar = false;
                    }
                }
                if (enviar && user != null)
                {
                    StringBuilder mensaje = new StringBuilder();
                    mensaje.Append(Strings.TelegramTrabajoCreado + " \n");
                    mensaje.Append(" - " + Strings.Nombre + a.Nombre + "\n - " + Strings.Fecha + a.Fecha + "\n - " + Strings.Precio + a.Precio + "€\n - " + Strings.Descripcion + a.Descripcion);
                    await MainWindow.client.SendMessageAsync(new TLInputPeerUser()
                    {
                        UserId = user.Id
                    }, mensaje.ToString());
                }
            }
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: teci98/TelERP
        private async void enviarMensaje(Stream tmp)
        {
            if (client.IsUserAuthorized())
            {
                var result = await client.GetContactsAsync();

                var user = result.Users
                           .Where(x => x.GetType() == typeof(TLUser))
                           .Cast <TLUser>()
                           .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                bool enviar = true;
                if (user == null)
                {
                    var phoneContact = new TLInputPhoneContact()
                    {
                        Phone = "34" + u.Telefono, FirstName = u.Nombre, LastName = u.Apellidos
                    };
                    var contacts = new List <TLInputPhoneContact>()
                    {
                        phoneContact
                    };
                    var req = new TLRequestImportContacts()
                    {
                        Contacts = new TLVector <TLInputPhoneContact>(contacts)
                    };
                    var rrr = await client.SendRequestAsync <TLImportedContacts>(req);

                    if (rrr.Imported.Count == 1)
                    {
                        user = result.Users
                               .Where(x => x.GetType() == typeof(TLUser))
                               .Cast <TLUser>()
                               .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                    }
                    else
                    {
                        enviar = false;
                    }
                }
                if (enviar && user != null)
                {
                    var fileResult = await client.UploadFile(Strings.Factura + i.Mes + "/" + i.Año, new StreamReader(tmp));

                    TLDocumentAttributeFilename name = new TLDocumentAttributeFilename();
                    name.FileName = Strings.Factura + i.Mes + "/" + i.Año + ".pdf";
                    await client.SendUploadedDocument(new TLInputPeerUser()
                    {
                        UserId = user.Id
                    }, fileResult, "", "application/pdf", new TLVector <TLAbsDocumentAttribute>() { name });
                }
            }
        }
コード例 #8
0
ファイル: TLSharpTests.cs プロジェクト: mojindri/TLSharp
        public async Task ImportContacts()
        {
            var contacts = new List <TLInputPhoneContact>();
            var client   = NewClient();
            await client.ConnectAsync();

            TLInputPhoneContact contact = new TLInputPhoneContact();

            contact.first_name = "John";
            contact.last_name  = "smith";
            contact.phone      = "+4917627060000";
            contacts.Add(contact);
            var result = await client.ImportContactsAsync(contacts);

            Assert.IsTrue(result.imported.lists.Count() > 0);
        }
コード例 #9
0
        private async void EditExecute()
        {
            var user = _item as TLUser;

            if (user == null)
            {
                return;
            }

            var confirm = await EditUserNameView.Current.ShowAsync(user.FirstName, user.LastName);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var contact = new TLInputPhoneContact
            {
                FirstName = EditUserNameView.Current.FirstName,
                LastName  = EditUserNameView.Current.LastName,
                Phone     = user.Phone
            };

            var response = await ProtoService.ImportContactsAsync(new TLVector <TLInputContactBase> {
                contact
            });

            if (response.IsSucceeded)
            {
                user.RaisePropertyChanged(() => user.HasFirstName);
                user.RaisePropertyChanged(() => user.HasLastName);
                user.RaisePropertyChanged(() => user.FirstName);
                user.RaisePropertyChanged(() => user.LastName);
                user.RaisePropertyChanged(() => user.FullName);
                user.RaisePropertyChanged(() => user.DisplayName);

                var dialog = CacheService.GetDialog(user.ToPeer());
                if (dialog != null)
                {
                    dialog.RaisePropertyChanged(() => dialog.With);
                }
            }
        }
コード例 #10
0
        private async void EditNameExecute()
        {
            if (_item == null)
            {
                return;
            }

            var confirm = await EditUserNameView.Current.ShowAsync(_item.FirstName, _item.LastName);

            if (confirm == ContentDialogResult.Primary)
            {
                var contact = new TLInputPhoneContact
                {
                    FirstName = EditUserNameView.Current.FirstName,
                    LastName  = EditUserNameView.Current.LastName,
                    Phone     = _item.Phone
                };

                var response = await ProtoService.ImportContactsAsync(new TLVector <TLInputContactBase> {
                    contact
                }, false);

                if (response.IsSucceeded)
                {
                    _item.RaisePropertyChanged(() => _item.FullName);
                    _item.RaisePropertyChanged(() => _item.FirstName);
                    _item.RaisePropertyChanged(() => _item.LastName);
                    _item.RaisePropertyChanged(() => _item.DisplayName);

                    var dialog = CacheService.GetDialog(_item.ToPeer());
                    if (dialog != null)
                    {
                        dialog.RaisePropertyChanged(() => dialog.With);
                    }
                }
            }
        }
コード例 #11
0
ファイル: ContactsService.cs プロジェクト: nazzi88ua/Unigram
        private async Task ImportAsync(ContactStore store)
        {
            var contacts = await store.FindContactsAsync();

            var importedPhones = new Dictionary <string, Contact>();

            foreach (var contact in contacts)
            {
                foreach (var phone in contact.Phones)
                {
                    importedPhones[phone.Number] = contact;
                }
            }

            var importedPhonesCache = GetImportedPhones();

            var importingContacts = new TLVector <TLInputContactBase>();
            var importingPhones   = new List <string>();

            foreach (var phone in importedPhones.Keys.Take(1300).ToList())
            {
                if (!importedPhonesCache.ContainsKey(phone))
                {
                    var contact   = importedPhones[phone];
                    var firstName = contact.FirstName ?? string.Empty;
                    var lastName  = contact.LastName ?? string.Empty;

                    if (string.IsNullOrEmpty(firstName) && string.IsNullOrEmpty(lastName))
                    {
                        if (string.IsNullOrEmpty(contact.DisplayName))
                        {
                            continue;
                        }

                        firstName = contact.DisplayName;
                    }

                    if (!string.IsNullOrEmpty(firstName) || !string.IsNullOrEmpty(lastName))
                    {
                        var item = new TLInputPhoneContact
                        {
                            Phone     = phone,
                            FirstName = firstName,
                            LastName  = lastName,
                            ClientId  = importedPhones[phone].GetHashCode()
                        };

                        importingContacts.Add(item);
                        importingPhones.Add(phone);
                    }
                }
            }

            if (importingContacts.IsEmpty())
            {
                return;
            }

            //base.IsWorking = true;
            _protoService.ImportContactsAsync(importingContacts, result =>
            {
                //Telegram.Api.Helpers.Execute.BeginOnUIThread(delegate
                //{
                //    this.IsWorking = false;
                //    this.Status = ((this.Items.get_Count() == 0 && this.LazyItems.get_Count() == 0 && result.Users.Count == 0) ? string.Format("{0}", AppResources.NoContactsHere) : string.Empty);
                //    int count = result.RetryContacts.Count;
                //    if (count > 0)
                //    {
                //        Telegram.Api.Helpers.Execute.ShowDebugMessage("contacts.importContacts error: retryContacts count=" + count);
                //    }
                //    this.InsertContacts(result.Users);
                //});

                _aggregator.Publish(new TLUpdateContactsReset());
                SaveImportedPhones(importedPhonesCache, importingPhones);
            },
                                              fault =>
            {
                Telegram.Api.Helpers.Execute.BeginOnUIThread(delegate
                {
                    //this.IsWorking = false;
                    //this.Status = string.Empty;
                    Telegram.Api.Helpers.Execute.ShowDebugMessage("contacts.importContacts error: " + fault);
                });
            });
        }
コード例 #12
0
        private async void enviarMensaje()
        {
            User        utmp  = new User();
            DataTable   uws   = utmp.userWithService(s.Idservice);
            List <User> lista = new List <User>();

            foreach (DataRow dr in uws.Rows)
            {
                utmp.recoverUser(int.Parse(dr["iduser"].ToString()));
                lista.Add(utmp);
            }


            if (MainWindow.client.IsUserAuthorized())
            {
                var result = await MainWindow.client.GetContactsAsync();

                foreach (User u in lista)
                {
                    var user = result.Users
                               .Where(x => x.GetType() == typeof(TLUser))
                               .Cast <TLUser>()
                               .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                    bool enviar = true;
                    if (user == null)
                    {
                        var phoneContact = new TLInputPhoneContact()
                        {
                            Phone = "34" + u.Telefono, FirstName = u.Nombre, LastName = u.Apellidos
                        };
                        var contacts = new List <TLInputPhoneContact>()
                        {
                            phoneContact
                        };
                        var req = new TLRequestImportContacts()
                        {
                            Contacts = new TLVector <TLInputPhoneContact>(contacts)
                        };
                        var rrr = await MainWindow.client.SendRequestAsync <TLImportedContacts>(req);

                        if (rrr.Imported.Count == 1)
                        {
                            user = result.Users
                                   .Where(x => x.GetType() == typeof(TLUser))
                                   .Cast <TLUser>()
                                   .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                        }
                        else
                        {
                            enviar = false;
                        }
                    }
                    if (enviar && user != null)
                    {
                        Turn          t       = new Turn();
                        DataRow       dr      = t.singleTurn(s.Refturn);
                        StringBuilder mensaje = new StringBuilder();
                        mensaje.Append(Strings.TelegramServicioModificado + " \n");
                        mensaje.Append(" - " + Strings.Nombre + s.Nombre + "\n - " + Strings.Dias + diasSemana(s.Dias.ToString()) + "\n - " + Strings.Precio + s.Precio + "€\n - " + Strings.Turno + dr[0].ToString() + " - " + dr[1].ToString() + "\n - " + Strings.Descripcion + s.Descripcion);
                        await MainWindow.client.SendMessageAsync(new TLInputPeerUser()
                        {
                            UserId = user.Id
                        }, mensaje.ToString());
                    }
                }
            }
        }
コード例 #13
0
        private async void obtenerFoto()
        {
            var result = await MainWindow.client.GetContactsAsync();

            var user = result.Users
                       .Where(x => x.GetType() == typeof(TLUser))
                       .Cast <TLUser>()
                       .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
            bool mirarfoto = true;

            if (user == null)
            {
                //await MainWindow.client.ConnectAsync();
                var phoneContact = new TLInputPhoneContact()
                {
                    Phone = "34" + u.Telefono, FirstName = u.Nombre, LastName = u.Apellidos
                };
                var contacts = new List <TLInputPhoneContact>()
                {
                    phoneContact
                };
                var req = new TLRequestImportContacts()
                {
                    Contacts = new TLVector <TLInputPhoneContact>(contacts)
                };
                var rrr = await MainWindow.client.SendRequestAsync <TLImportedContacts>(req);

                if (rrr.Imported.Count == 1)
                {
                    user = result.Users
                           .Where(x => x.GetType() == typeof(TLUser))
                           .Cast <TLUser>()
                           .FirstOrDefault(x => x.Phone == "34" + u.Telefono);
                }
                else
                {
                    mirarfoto = false;
                }
            }
            if (mirarfoto && user != null)
            {
                TLAbsUserProfilePhoto photo = user.Photo;
                TLUserProfilePhoto    up    = (TLUserProfilePhoto)photo;
                if (up != null && up.PhotoBig != null)
                {
                    TLFileLocation         tf   = (TLFileLocation)up.PhotoBig;
                    TLAbsInputFileLocation aifl = new TLInputFileLocation()
                    {
                        LocalId  = tf.LocalId,
                        Secret   = tf.Secret,
                        VolumeId = tf.VolumeId
                    };
                    TeleSharp.TL.Upload.TLFile buffer = await MainWindow.client.GetFile(aifl, 1024 * 1024);

                    if (buffer.Bytes != null)
                    {
                        u.Photo = buffer.Bytes;
                        u.cambiarFoto();
                    }
                }
            }
        }
コード例 #14
0
ファイル: TelegramService.cs プロジェクト: jorgelg/TelegramWS
        public async Task <Respuestas> EnviarMensajeAUsuarioN(Mensaje nuevo, string pathArchivo, string nombreUsuario = "")
        {
            Respuestas respuesta = new Respuestas();

            try
            {
                var numeroformateado = nuevo.NumeroDestino.StartsWith("+") ?
                                       nuevo.NumeroDestino.Substring(1) :
                                       nuevo.NumeroDestino;
                contexto = Iniciar();
                await contexto.ConnectAsync();

                var nvoContacto = new TLInputPhoneContact()
                {
                    Phone = numeroformateado, FirstName = ((string.IsNullOrEmpty(nuevo.NombreNuevoUsuario) ? "user" + numeroformateado : nuevo.NombreNuevoUsuario)), LastName = string.Empty
                };

                var req = new TLRequestImportContacts()
                {
                    Contacts = new TLVector <TLInputPhoneContact>()
                    {
                        nvoContacto
                    }
                };
                var resultado = await contexto.SendRequestAsync <TLImportedContacts>(req);

                //aqui carga 1ro infaliblemente el user_id 1ro... y es extraible...
                if (resultado.Users.Count > 0)
                {
                    var idnuevo        = resultado.Users.OfType <TLUser>().ElementAtOrDefault(0).Id;
                    var usuarioDestino = resultado.Users.OfType <TLUser>().FirstOrDefault(x => x.Id == idnuevo);
                    if (usuarioDestino == null)
                    {
                        respuesta.MESSAGE = "No se encontro usuario Destino, verifique que sea un número telefónico asociado a una cuenta Telegram...";
                        respuesta.STATUS  = false;
                        return(respuesta);
                    }
                    bool completado = false;
                    completado = await contexto.SendTypingAsync(new TLInputPeerUser()
                    {
                        UserId = usuarioDestino.Id
                    });

                    await Task.Delay(3000);

                    if (completado)
                    {
                        await contexto.SendMessageAsync(new TLInputPeerUser()
                        {
                            UserId = usuarioDestino.Id
                        }, nuevo.TextoContenido);
                    }
                    else
                    {
                        respuesta.MESSAGE = "No se pudo sincronizar con Telegram, intente nuevamente o pruebe reautenticando...";
                        respuesta.STATUS  = false;
                        return(respuesta);
                    }
                    respuesta.MESSAGE = "Mensaje enviado exitosamente a: " + numeroformateado;
                    respuesta.STATUS  = true;
                    return(respuesta);
                }
                else
                {
                    respuesta.MESSAGE = "Error interno, no se pudo enviar mensaje a nuevo usuario";
                    respuesta.STATUS  = false;
                    return(respuesta);
                }
            }
            catch (Exception e)
            {
                respuesta.MESSAGE = "No se pudo enviar mensaje error: " + e.Message;
                respuesta.STATUS  = false;
                return(respuesta);
            }
        }
コード例 #15
0
ファイル: TelegramService.cs プロジェクト: jorgelg/TelegramWS
        public async Task <Respuestas> EnviarImagenAUsuarioN(Mensaje nuevo)
        {
            Respuestas respuesta = new Respuestas();

            try
            {
                var numeroformateado = nuevo.NumeroDestino.StartsWith("+") ?
                                       nuevo.NumeroDestino.Substring(1) :
                                       nuevo.NumeroDestino;
                contexto = Iniciar();
                await contexto.ConnectAsync();

                var nvoContacto = new TLInputPhoneContact()
                {
                    Phone = numeroformateado, FirstName = ((string.IsNullOrEmpty(nuevo.NombreNuevoUsuario) ? "user" + numeroformateado : nuevo.NombreNuevoUsuario)), LastName = string.Empty
                };
                var contactos = new List <TLInputPhoneContact>()
                {
                    nvoContacto
                };

                var req = new TLRequestImportContacts()
                {
                    Contacts = new TLVector <TLInputPhoneContact>()
                    {
                        nvoContacto
                    }
                };
                var resultado = await contexto.SendRequestAsync <TLImportedContacts>(req);

                //aqui carga 1ro infaliblemente el user_id 1ro... y es extraible...
                if (resultado.Users.Count > 0)
                {
                    var idnuevo        = resultado.Users.OfType <TLUser>().ElementAtOrDefault(0).Id;
                    var usuarioDestino = resultado.Users.OfType <TLUser>().FirstOrDefault(x => x.Id == idnuevo);
                    if (usuarioDestino == null)
                    {
                        respuesta.MESSAGE = "No se encontro usuario Destino, verifique que sea un número telefónico asociado a una cuenta Telegram...";
                        respuesta.STATUS  = false;
                        return(respuesta);
                    }


                    MemoryStream imagen = new MemoryStream(Convert.FromBase64String(nuevo.Imagen));
                    //var im = Image.FromStream(imagen);
                    //Image imagen_redimensionada = ResizeImage(im, 300, 60);
                    //args.Image = imagen_redimensionada;
                    StreamReader imageStream = new StreamReader(imagen); //verificar encoding

                    var archivo = new TLInputFile();
                    archivo = (TLInputFile)await contexto.UploadFile("Image" + (new Random().Next()) + ".jpg", imageStream);

                    if (archivo != null)
                    {
                        await contexto.SendUploadedPhoto(new TLInputPeerUser()
                        {
                            UserId = usuarioDestino.Id
                        }, archivo, nuevo.DescripcionImagen);

                        respuesta.MESSAGE = "Imagen enviada a: " + numeroformateado;
                        respuesta.STATUS  = true;
                        return(respuesta);
                    }
                    else
                    {
                        respuesta.MESSAGE = "No se pudo enviar imagen, ERROR INTERNO...";
                        respuesta.STATUS  = false;
                        return(respuesta);
                    }
                }
                else
                {
                    respuesta.MESSAGE = "Error interno, no se pudo enviar mensaje a nuevo usuario";
                    respuesta.STATUS  = false;
                    return(respuesta);
                }
            }
            catch (Exception e)
            {
                respuesta.MESSAGE = "No se pudo enviar mensaje error: " + e.Message;
                respuesta.STATUS  = false;
                return(respuesta);
            }
        }