public async Task SignUpNewUser() { var store = new FileSessionStore(); var client = new TelegramClient(store, "session", apiId, apiHash); await client.Connect(); var hash = await client.SendCodeRequest(NotRegisteredNumberToSignUp); var code = ""; var registeredUser = await client.SignUp(NotRegisteredNumberToSignUp, hash, code, "TLSharp", "User"); Assert.IsNotNull(registeredUser); Assert.IsTrue(client.IsUserAuthorized()); var loggedInUser = await client.MakeAuth(NotRegisteredNumberToSignUp, hash, code); Assert.IsNotNull(loggedInUser); }
public async Task AuthUser() { var store = new FileSessionStore(); var client = new TelegramClient(store, "session"); await client.Connect(); var hash = await client.SendCodeRequest(NumberToAuthenticate); var code = "123"; // you can change code in debugger var user = await client.MakeAuth(NumberToAuthenticate, hash, code); Assert.IsNotNull(user); }
public async Task AuthUser() { var store = new FileSessionStore(); var client = new TelegramClient(store, "session"); await client.Connect(); var hash = await client.SendCodeRequest("375257307554"); var code = "70342"; // you can change code in debugger var t = Console.ReadLine(); code = t; var user = await client.MakeAuth("375257307554", hash, code); Console.WriteLine("fdfdfdfd"); var userByPhoneId = await client.ImportContactByPhoneNumber("375293088998"); await client.SendMessage(userByPhoneId.Value, "Hello Habr!"); Assert.IsNotNull(user); var hist = await client.GetMessagesHistoryForContact(userByPhoneId.Value, 0, 1000); hist.Count(); }