public async Task GetMeTest()
        {
            var client = new TelegramBot("161652985:AAHg3nbjt1AduvFzRisQWMsk8ooWl6flx6I");
            var getMe = await client.GetMe();

            Assert.IsNotNull(getMe.Id, getMe.FirstName, getMe.LastName, getMe.Username);
            Console.WriteLine($"[ID:{getMe.Id}] {getMe.FirstName} {getMe.LastName} with username {getMe.Username}");
        }
示例#2
0
        public void GetMe_Returns_User()
        {
            var u = _b.GetMe();

            Assert.IsNotNull(u);
            Assert.IsNotNull(u.FirstName);
            Assert.IsNotNull(u.Username);
            Assert.That(u.Id > 0);
            Assert.IsTrue(u.IsBot);
        }
示例#3
0
        public static async Task Main()
        {
            Bot = new TelegramBot($"{BotToken}");
            var me = await Bot.GetMe();

            Console.WriteLine($"Bot name: @{me.Username}");

            var subscription = Bot.Updates.Message.Subscribe(HandleReceivedMessage);

            Console.ReadLine();
            subscription.Dispose();
        }
示例#4
0
        public static async Task Main()
        {
            Bot = new TelegramBot($"{BotToken}");
            var me = await Bot.GetMe();

            Console.WriteLine($"Bot name: @{me.Username}");

            var subscriptionMessage = Bot.Updates.Message.Subscribe(HandleReceivedMessage,
                                                                    exception => Console.WriteLine($"An error has occured: {exception.Message}"));
            var subscriptionCallbackQuery = Bot.Updates.CallbackQuery.Subscribe(HandleCallbackQuery,
                                                                                exception => Console.WriteLine($"An error has occured: {exception.Message}"));

            Console.ReadLine();
            subscriptionMessage.Dispose();
            subscriptionCallbackQuery.Dispose();
        }
        public static async Task Main()
        {
            var bot = new TelegramBot($"{BotToken}");
            var me  = await bot.GetMe();

            Console.WriteLine($"Bot name: @{me.Username}");

            var subscription = bot.Updates.Message.Subscribe(x =>
            {
                bot.SendMessage(new SendMessage
                {
                    ChatId = x.Chat.Id,
                    Text   = x.Text
                });
            },
                                                             exception => Console.WriteLine($"An error has occured: {exception.Message}"));

            Console.ReadLine();
            subscription.Dispose();
        }