/// <summary> /// Primiry constructor of a class. /// </summary> /// <param name="token">Telegram bot token.</param> /// <param name="lastUpdateId">Last update ID used as offset in Telegram's api getUpdates function. Default value is 0.</param> public LongPollingUpdates(string token, int lastUpdateId = 0) { Token = token; LastUpdateId = lastUpdateId; _requestMonitorTimer = new System.Timers.Timer { Interval = MaxDelayServerResponse, AutoReset = true }; _telegramMethods = new TelegramMethods(token); _requestMonitorTimer.Elapsed += RequestMonitorTimer_Elapsed; }
public static void ClassInitialize(TestContext context) { _telegramMessagesCount = 0; _config = new ComparisonConfig { CompareChildren = true, CompareFields = false, CompareReadOnly = true, ComparePrivateFields = false, ComparePrivateProperties = false, CompareProperties = true, MaxDifferences = 50, MembersToIgnore = new List<string> { "MessageId", "Date", "ForwardDate", "UpdateId" } }; var rm = new ResourceManager("CoffeeJelly.TelegramBotApiWrapperTests.Token", Assembly.GetExecutingAssembly()); var token = rm.GetString("testToken"); _telegramMethods = new TelegramMethods(token, true); var t = _telegramMethods.DeleteWebhook().Result; _privateChat = new Chat { Id = 170181775, FirstName = "Coffee", LastName = "Jelly", Username = "******", Type = ChatType.Private }; _botUser = new User { Id = 252886092, FirstName = "Gmail control bot", Username = "******" }; _italicTextEntity = new MessageEntity { Type = MessageEntityType.Italic, Offset = 0, Length = 23 }; _urlEntity = new MessageEntity { Type = MessageEntityType.Url, Offset = 0, Length = 21 }; _testUrlButton = new InlineKeyboardButton { Text = "URL Button", Url = "https://www.twitch.tv" }; _testCallbackDataButton = new InlineKeyboardButton { Text = "Callback Button", CallbackData = "Test callback data" }; _testInlineKeyboardMarkup = new InlineKeyboardMarkup { InlineKeyboard = new List<List<InlineKeyboardButton>> { new List<InlineKeyboardButton> { _testUrlButton, _testCallbackDataButton } } }; _testTextKeyboardButton = new KeyboardButton { Text = "Test keyboard button" }; _testContactKeyboardButton = new KeyboardButton { Text = "Test contact keyboard button", RequestContact = true }; _testReplyKeyboardMarkup = new ReplyKeyboardMarkup { Keyboard = new List<List<KeyboardButton>> { new List<KeyboardButton> { _testTextKeyboardButton, _testContactKeyboardButton, }, new List<KeyboardButton> { _testContactKeyboardButton } } }; _testReplyKeyboardRemove = new ReplyKeyboardRemove(); _testForceReply = new ForceReply(); _botStartCommandEntity = new MessageEntity { Type = MessageEntityType.BotCommand, Offset = 0, Length = 6 }; _user = new User { Id = 170181775, FirstName = "Coffee", LastName = "Jelly", Username = "******", LanguageCode = "en" }; _location = new Location { Latitude = 53.901112F, Longitude = 27.562325F }; _photoSize1 = new PhotoSize { FileId = "AgADAgADqqcxG4_EJAo-Knthid_Ygy4XSA0ABHFCoFI0_mWuqGEBAAEC", FileSize = 10311, Width = 160, Height = 160 }; _photoSize2 = new PhotoSize { FileId = "AgADAgADqqcxG4_EJAo-Knthid_Ygy4XSA0ABII7yIDVjT7yqWEBAAEC", FileSize = 22094, Width = 320, Height = 320 }; _photoSize3 = new PhotoSize { FileId = "AgADAgADqqcxG4_EJAo-Knthid_Ygy4XSA0ABEN3DhgGCbBFqmEBAAEC", FileSize = 57644, Width = 640, Height = 640 }; _userProfilePhotos = new UserProfilePhotos { TotalCount = 1, Photos = new List<List<PhotoSize>> { new List<PhotoSize> { _photoSize1, _photoSize2, _photoSize3 } } }; _file = new File { FileId = "CAADAgADLgADk35wS_5j0ImZMegiAg", }; _supergroupChat = new Chat { Id = -1001076966401, Title = "testgrp_new_title", Type = ChatType.Supergroup }; _testChannel = new Chat { Id = -1001114442404, Title = "TestChannel", Type = ChatType.Channel }; _userChatMember = new ChatMember { Status = ChatMemberStatus.Creator, User = _user }; _botChatMember = new ChatMember { Status = ChatMemberStatus.Administrator, User = _botUser }; _githubBot = new User { Id = 107550100, FirstName = "GitHub", Username = "******" }; _githubBotChatMember = new ChatMember { Status = ChatMemberStatus.Administrator, User = _githubBot }; }
public async Task GetMe_TelegramMethodsGetMeException() { var telegramMethods = new TelegramMethods("fakeToken"); var actual = await telegramMethods.GetMe(); }
/// <summary> /// Primiry constructor of a class. /// </summary> /// <param name="token">Telegram bot token.</param> public WebhookUpdates(string token) { _telegramMethods = new TelegramMethods(token); }