Exemple #1
-1
		public async Task ImportContactByPhoneNumber()
		{
			// User should be already authenticated!

			var store = new FileSessionStore();
			var client = new TelegramClient(store, "session");
			
			await client.Connect();

			Assert.IsTrue(client.IsUserAuthorized());

			var res = await client.ImportContactByPhoneNumber(NumberToSendMessage);

			Assert.IsNotNull(res);
		}
Exemple #2
-1
        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();
        }
Exemple #3
-1
		public async Task UploadAndSendMedia()
		{
			var store = new FileSessionStore();
			var client = new TelegramClient(store, "session");
			await client.Connect();

			Assert.IsTrue(client.IsUserAuthorized());

			var res = await client.ImportContactByPhoneNumber(NumberToSendMessage);

			Assert.IsNotNull(res);
			const string testFile = "TEST";

			var file = File.ReadAllBytes("../../data/cat.jpg");

			var mediaFile = await client.UploadFile("test_file.jpg", file);

			Assert.IsNotNull(mediaFile);

			var state = await client.SendMediaMessage(res.Value, mediaFile);

			Assert.IsTrue(state);
		}
Exemple #4
-1
		public async Task GetHistory()
		{
			var store = new FileSessionStore();
			var client = new TelegramClient(store, "session");
			await client.Connect();

			Assert.IsTrue(client.IsUserAuthorized());

			var res = await client.ImportContactByPhoneNumber(NumberToSendMessage);

			Assert.IsNotNull(res);

			var hist = await client.GetMessagesHistoryForContact(res.Value, 0, 5);

			Assert.IsNotNull(hist);
		}