TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

Importing Contacts

Open armanforghani opened this issue 8 years ago • 7 comments

What is the usage of this library when there is no way to import new contacts? Telegram is a social network and the user may want to contact new friend. Even with this library we cannot reply to received messages. As far as i can remember this feature was available in previous version.

armanforghani avatar Jan 18 '17 18:01 armanforghani

Here, catch.

TeleSharp.TL.Contacts.TLRequestImportContacts requestImportContacts = new TeleSharp.TL.Contacts.TLRequestImportContacts();
            requestImportContacts.contacts = new TLVector<TLInputPhoneContact>();
            requestImportContacts.contacts.lists.Add(new TLInputPhoneContact()
            {
                phone = "79000000000",
                first_name = "",
                last_name = ""
            });
            var o = await client.SendRequestAsync<TeleSharp.TL.Contacts.TLImportedContacts>((TLMethod)requestImportContacts);
            var NewUserId = (o.users.lists.First() as TLUser).id;
            var d = await client.SendMessageAsync(new TLInputPeerUser() { user_id = NewUserId }, "text");

I'm using this code at 0.0.10. and 0.1.0.218 version

ayazzali avatar Feb 16 '17 14:02 ayazzali

do i need specific permission? ON: var o = await client.SendRequestAsync<TeleSharp.TL.Contacts.TLImportedContacts>((TLMethod)requestImportContacts);

GET: [NullReferenceException: Object reference not set to an instance of an object.] TLSharp.Core.<SendRequestAsync>d__181.MoveNext() +118 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() +28 MessageSender.Controllers.<ImportContacts>d__4.MoveNext() in C:\Users\Faghihi\Documents\Visual Studio 2015\Projects\MessageSender\MessageSender\Controllers\HomeController.cs:62 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +17 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +22 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765901 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

deadmann avatar Aug 14 '17 08:08 deadmann

I write a code and send for example 1000 contacts per request and no error or exception @sochix

TLVector<TLInputPhoneContact> v=new TLVector<TLInputPhoneContact>();
            for (int i = 0; i < 100; i++)
            {
                TLInputPhoneContact p = new TLInputPhoneContact();
                p.FirstName = dataGridView1.Rows[i].Cells["AName"].Value.ToString();
                p.LastName =  dataGridView1.Rows[i].Cells["AFamily"].Value.ToString();
                p.Phone = dataGridView1.Rows[i].Cells["AMobile"].Value.ToString();
                v.Add(p);

            }
            var resultImportcontacts = await client.RequestImportContacts(v, true); 

but output for resultImportcontacts not rightly Imported=0 RetryContacts=81 Users=0 somtimes work only for 5 or 3 or 2 in 1000 importedcontacts in first import but after many import output always 0 i think this function has limitation by Telegram!!! Once it works, it does not work once this is big problem why?

jjorian avatar Mar 12 '18 09:03 jjorian

@jjorian There's no RequestImportContacts function under TelegramClient object, I can't find it

jefferyleo avatar Apr 20 '18 04:04 jefferyleo

@jefferyleo yes but you can add it to source and use it

jjorian avatar Apr 30 '18 11:04 jjorian

@jefferyleo yes but you can add it to source and use it

Can find a way to fix this issue???

Painkiller1991 avatar Mar 04 '19 08:03 Painkiller1991

@jjorian How you solved it? I have the same isue. When I import contacts, sometimes it does, sometimes it doesn't. Even the numbers I added (and removed manually) Telegram doesn't added when I try again. It's frustrating.

D4L4M4R avatar Mar 15 '21 11:03 D4L4M4R