/// <summary> /// Bot's work process /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void backgroundWorkerProcess_DoWorkAsync(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; var key = e.Argument as string; // получаем ключ из аргументов try { var webProxy = new WebProxy("198.199.91.20:3128", true); var Bot = new Telegram.Bot.TelegramBotClient(key, webProxy); await Bot.SetWebhookAsync(""); //USE VPN int offset = 0; // отступ по сообщениям while (true) { var updates = await Bot.GetUpdatesAsync(offset); foreach (var update in updates) { var message = update.Message; /* * Test message * if (message.Text == "/saysomething") * { * // в ответ на команду /saysomething выводим сообщение * await Bot.SendTextMessageAsync(message.Chat.Id, "тест", * replyToMessageId: message.MessageId); * } */ if (message.Text == "/random") { string pageText = AnekdotParsing.LoadPage(randomAnekdotPage); string[] data = AnekdotParsing.ParseData(pageText); string reply = string.Empty; foreach (string str in data) { reply += str + "\n"; } await Bot.SendTextMessageAsync(message.Chat.Id, reply); } offset = update.Id + 1; } } } catch (Telegram.Bot.Exceptions.ApiRequestException ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { //bot.loadSettings(); bot.OnMessage += BotOnMessage; bot.SetWebhookAsync(); var me = bot.GetMeAsync().Result; Console.Title = me.Username; bot.StartReceiving(); Console.ReadLine(); bot.StopReceiving(); }
public async void StartBot() { try { await Bot.SetWebhookAsync(""); //users = db.Users.ToList(); //allbets = db.Bets.Where(b => b.BetSTIplus == 0 & !b.IsLocked).ToList(); //timer.Enabled = true; //timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); } catch { } }
public override async void bw_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; var key = e.Argument as string; try { var Bot = new Telegram.Bot.TelegramBotClient(key); await Bot.SetWebhookAsync(""); int offset = 0; while (true) { var updates = await Bot.GetUpdatesAsync(offset); foreach (var v in updates) { var message = v.Message; if (message == null) { return; } int idCurrentUser = dataBase.IdCurrentUser(message.From.Id); if (idCurrentUser == 0) //если ID не найден, то создаем и добавляем нового клиента и присваиваем ему индек последнего объекта { dataBase.AddUser(message.From.Id.ToString(), message.Chat.Id.ToString(), OperatingMode.AddGoal); //add new user await Bot.SendTextMessageAsync(message.Chat.Id, "Приветствуем Вас.\nВведите от 3 до 15 целей, которые необходимо достичь.", replyMarkup : KeyBoard()); } else { IUser user = new User(dataBase, idCurrentUser, message, dataBase.GetUserMod(idCurrentUser)); await Bot.SendTextMessageAsync(message.Chat.Id, (user.Message = message).Text, replyMarkup : KeyBoard()); } offset = v.Id + 1; } } } catch (Telegram.Bot.Exceptions.ApiRequestException ex) { Console.WriteLine(ex.Message); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // Setup telegram client var accessToken = Configuration["Settings:accessToken"]; var bot = new Telegram.Bot.TelegramBotClient(accessToken); // Set up webhook string webhookUrl = Configuration["Settings:webhookUrl"]; int maxConnections = int.Parse(Configuration["Settings:maxConnections"]); bot.SetWebhookAsync(webhookUrl, maxConnections: maxConnections, allowedUpdates: new [] { Telegram.Bot.Types.Enums.UpdateType.Message, Telegram.Bot.Types.Enums.UpdateType.CallbackQuery }); services.AddScoped <ITelegramBotClient>(client => bot); var storageConnectionString = Configuration["Settings:storageConnectionString"]; var storage = new StorageAzure(storageConnectionString); services.AddScoped <IStorageAzure>(client => storage); services.AddScoped <IStorage, StorageAzureAdapter>(); services.AddScoped <ISubscribesDataAccess, SubscribesDataAccess>(); services.AddScoped <ISubscribesDataAccess, SubscribesDataAccess>(); services.AddScoped <ISettingsDataAccess, SettingsDataAccess>(); services.AddScoped <IDataAccess, DataAccess>(); services.AddScoped <ISettings, Settings>(); //services.AddHostedService<ScheduleTask>(); services.AddSingleton <IHostedService, ScheduleTask>(); }
private async void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; var key = e.Argument as String; try { var Bot = new Telegram.Bot.TelegramBotClient(key); Bot.SetWebhookAsync("").Wait(); int offset = 0; int stageM = 0; while (true) { var updates = await Bot.GetUpdatesAsync(offset); foreach (var update in updates) { var message = update.Message; stageM = 0; int index = -1; for (int i = 0; i < persons.Count; i++) { if (persons[i].userid == message.From.Id) { index = i; break; } } if (message.Type == Telegram.Bot.Types.Enums.MessageType.TextMessage) { if (message.Text == "/reset" && index >= 0) { persons.RemoveAt(index); await Bot.SendTextMessageAsync(message.Chat.Id, "Ваш профиль очищен."); } else if (message.Text == "/reset") { await Bot.SendTextMessageAsync(message.Chat.Id, "Профиль чист."); } else { if (index >= 0) { stageM = persons[index].stage; } else { persons.Add(new Person { FirstName = message.From.FirstName, SecondName = message.From.LastName, gender = 0, temperament = "", bd = 0, bm = 0, by = 0, userid = message.From.Id, stage = 0 }); index = persons.Count - 1; stageM = 0; } switch (stageM) { case 0: Telegram.Bot.Types.FileToSend file = new Telegram.Bot.Types.FileToSend(); file.Content = File.Open("hello.jpg", FileMode.Open); file.Filename = "hello.jpg"; await Bot.SendPhotoAsync(message.Chat.Id, file); await Bot.SendTextMessageAsync(message.Chat.Id, "Привет, " + message.From.FirstName + "!\nЯ Миша.\nЯ постараюсь быть тебе другом.\nРасскажи немного о себе😊"); var keyboard = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] // row 1 { new Telegram.Bot.Types.KeyboardButton("👨Мужской"), new Telegram.Bot.Types.KeyboardButton("👱♀Женский") }, }, ResizeKeyboard = true, OneTimeKeyboard = true }; await Bot.SendTextMessageAsync(message.Chat.Id, "Укажи свой пол", ParseMode.Default, false, false, 0, keyboard); stageM++; break; case 1: if (message.Text == "👨Мужской") { persons[index].gender = 1; } else if (message.Text == "👱♀Женский") { persons[index].gender = 2; } else { stageM--; break; } var keyboard1 = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] // row 1 { new Telegram.Bot.Types.KeyboardButton("👍Хорошо"), new Telegram.Bot.Types.KeyboardButton("😞Плохо"), new Telegram.Bot.Types.KeyboardButton("😐Не очень") }, }, ResizeKeyboard = true, OneTimeKeyboard = true }; await Bot.SendTextMessageAsync(message.Chat.Id, "Как прошел твой день?", ParseMode.Default, false, false, 0, keyboard1); stageM++; break; case 2: bool inGame = false; int indexgame = -1; int indexGamer = 0; string pathGamePhoto = ""; for (int i = 0; i < gamesphoto.Count; i++) { if (gamesphoto[i].user1 == message.From.Id || gamesphoto[i].user2 == message.From.Id || gamesphoto[i].user3 == message.From.Id || gamesphoto[i].user4 == message.From.Id) { inGame = true; indexgame = i; } } if (!inGame) { await Bot.SendTextMessageAsync(message.Chat.Id, "Я понял. Давай сыграем в игру, где надо будет собрать части картинки в одну. Я отправлю картинки всем в твоей команде и ты должен найти недостающие части."); } else if (gamesphoto[indexgame].count == 4) { if (message.Text.ToLower() == "кот" || message.Text.ToLower() == "котик" || message.Text.ToLower() == "кошка") { await Bot.SendTextMessageAsync(message.Chat.Id, "Правильно!"); var keyboard6 = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] // row 1 { new Telegram.Bot.Types.KeyboardButton("Учился в школе"), new Telegram.Bot.Types.KeyboardButton("Гуляли с друзьями"), new Telegram.Bot.Types.KeyboardButton("Справляли день рождения"), new Telegram.Bot.Types.KeyboardButton("Ничего") }, }, ResizeKeyboard = true, OneTimeKeyboard = true }; await Bot.SendTextMessageAsync(message.Chat.Id, "Что запомнилось тебе за этот день?", ParseMode.Default, false, false, 0, keyboard6); stageM++; break; } else { await Bot.SendTextMessageAsync(message.Chat.Id, "Подумай еще!😊"); break; } } if (!inGame) { for (int i = 0; i < gamesphoto.Count; i++) { if (gamesphoto[i].count != 4) { if (gamesphoto[i].user1 == -1) { gamesphoto[i].chatID1 = message.Chat.Id; gamesphoto[i].user1 = message.From.Id; pathGamePhoto = gamesphoto[i].firstPath; } else if (gamesphoto[i].user2 == -1) { indexGamer = 1; gamesphoto[i].chatID2 = message.Chat.Id; gamesphoto[i].user2 = message.From.Id; pathGamePhoto = gamesphoto[i].secondPath; } else if (gamesphoto[i].user3 == -1) { indexGamer = 2; gamesphoto[i].chatID3 = message.Chat.Id; gamesphoto[i].user3 = message.From.Id; pathGamePhoto = gamesphoto[i].thirdPath; } else if (gamesphoto[i].user4 == -1) { indexGamer = 3; gamesphoto[i].chatID4 = message.Chat.Id; gamesphoto[i].user4 = message.From.Id; pathGamePhoto = gamesphoto[i].fourPath; } inGame = true; indexgame = i; gamesphoto[indexgame].count++; if (gamesphoto[indexgame].count == 4) { Telegram.Bot.Types.FileToSend file1 = new Telegram.Bot.Types.FileToSend(); file1.Content = File.Open(gamesphoto[indexgame].firstPath, FileMode.Open); file1.Filename = gamesphoto[indexgame].firstPath; await Bot.SendPhotoAsync(gamesphoto[indexgame].chatID1, file1); await Bot.SendTextMessageAsync(gamesphoto[indexgame].chatID1, "Найди другие части картинки и скажи что на картинке. Удачи!😊"); file1.Content = File.Open(gamesphoto[indexgame].secondPath, FileMode.Open); file1.Filename = gamesphoto[indexgame].secondPath; await Bot.SendPhotoAsync(gamesphoto[indexgame].chatID2, file1); await Bot.SendTextMessageAsync(gamesphoto[indexgame].chatID2, "Найди другие части картинки и скажи что на картинке. Удачи!😊"); file1.Content = File.Open(gamesphoto[indexgame].thirdPath, FileMode.Open); file1.Filename = gamesphoto[indexgame].thirdPath; await Bot.SendPhotoAsync(gamesphoto[indexgame].chatID3, file1); await Bot.SendTextMessageAsync(gamesphoto[indexgame].chatID3, "Найди другие части картинки и скажи что на картинке. Удачи!😊"); file1.Content = File.Open(gamesphoto[indexgame].fourPath, FileMode.Open); file1.Filename = gamesphoto[indexgame].fourPath; await Bot.SendPhotoAsync(gamesphoto[indexgame].chatID4, file1); await Bot.SendTextMessageAsync(gamesphoto[indexgame].chatID4, "Найди другие части картинки и скажи что на картинке. Удачи!😊"); break; } } } } if (!inGame) { await Bot.SendTextMessageAsync(message.Chat.Id, "Игр пока нет😊"); } else { if (gamesphoto[indexgame].count != 4) { await Bot.SendTextMessageAsync(message.Chat.Id, "Подожди немного, я поищу тебе команду😊"); } } break; case 3: persons[index].answer2 = message.Text; var keyboard3 = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] // row 1 { new Telegram.Bot.Types.KeyboardButton("Да"), new Telegram.Bot.Types.KeyboardButton("Нет"), }, }, ResizeKeyboard = true, OneTimeKeyboard = true }; await Bot.SendTextMessageAsync(message.Chat.Id, "Понравилось ли тебе сегодняшнее задание?", ParseMode.Default, false, false, 0, keyboard3); stageM++; break; case 4: persons[index].answer3 = message.Text; await Bot.SendTextMessageAsync(message.Chat.Id, "Какое задание ты сегодня выполнял?"); stageM++; break; case 5: persons[index].answer4 = message.Text; var keyboard5 = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] // row 1 { new Telegram.Bot.Types.KeyboardButton("Да"), new Telegram.Bot.Types.KeyboardButton("Нет"), }, }, ResizeKeyboard = true, OneTimeKeyboard = true }; await Bot.SendTextMessageAsync(message.Chat.Id, "У тебя есть чем поделиться со мной?", ParseMode.Default, false, false, 0, keyboard5); stageM++; break; case 6: if (message.Text.ToLower() == "нет") { await Bot.SendTextMessageAsync(message.Chat.Id, "До завтра!"); } else if (message.Text.ToLower() == "да") { await Bot.SendTextMessageAsync(message.Chat.Id, "Излагай свои мысли"); } stageM++; break; case 7: persons[index].answer5 += message.Text + Environment.NewLine; break; } ; persons[index].stage = stageM; } offset = update.Id + 1; } } } } catch (Telegram.Bot.Exceptions.ApiRequestException ex) { MessageBox.Show(ex.Message); } }
//listing https://support.hbtc.co/hc/en-us/sections/360009462813-New-Listings // Notice https://support.hbtc.co/hc/en-us/sections/360009462793-Withdrawal-Opening-Suspension-Notice // others https://support.hbtc.co/hc/en-us/sections/360001994473-Others async void bw_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; try { ; // инициализируем API try { await Bot.SetWebhookAsync(""); // !!!!!!!!!!!!!!!!!!!!!!ЦИКЛ ПЕРЕЗАПУСКА } catch { await Bot.SetWebhookAsync(""); } { /* * // Inlin'ы * Bot.OnMessage += async (object sender2, Telegram.Bot.Args.MessageEventArgs e1) => * * Bot.StartReceiving(Array.Empty<UpdateType>()); * var timer = new Timer(); * timer.Interval = 7000; * timer.Tick += new EventHandler(SimpleFunc); //И печатает на экран что-то * timer.Start(); * * void SimpleFunc(object sendear, EventArgs e2) * { * if (link_pars != link_new) * { * * link_pars = link_new; * } * * System.Net.WebClient wc1 = new System.Net.WebClient(); * String link_Response = wc1.DownloadString("https://support.hbtc.co/hc/en-us/sections/360002667194-Recent-Activities"); * link_new = System.Text.RegularExpressions.Regex.Match(link_Response, @"(/hc/en-us/articles)+(.+)(?="" class)").Groups[0].Value; * Bot.SendTextMessageAsync(@"pesik123d", "", ParseMode.Html, false, false, 0, null); * if (Form1.count != 0) * { * Bot.SendTextMessageAsync(@"pesik123d", "", ParseMode.Html, false, false, 0, null); * } * Form1.count++; * Task.Delay(60000); * } * * Bot.StopReceiving(); * * }; * * Bot.OnCallbackQuery += async (object sc, Telegram.Bot.Args.CallbackQueryEventArgs ev) => * { * * }; */ Bot.OnUpdate += async(object su, Telegram.Bot.Args.UpdateEventArgs evu) => { try { var update = evu.Update; var message = update.Message; if (message == null) { return; } /* * if (question1.Count == 2 || message.From.Username == @"off_fov") * { * question1[1] = message.Text; * await Bot.SendTextMessageAsync(message.Chat.Id, question1[0] + "\n" + question1[1], ParseMode.Html, false, false, 0, keyboard_full); * await Bot.SendTextMessageAsync(message.Chat.Id, @"Вопрос ответ! Добавлен", ParseMode.Html, false, false, 0, keyboard_full); * * }*/ if (message.Text == "/win" & message.From.Username == @"off_fov") { await Bot.SendTextMessageAsync(message.Chat.Id, @"сам макака", ParseMode.Html, false, false, 0, null); } // https://www.hbtc.com/api/v1/hobbit/repurchase/info // @"https://api.hbtc.com/openapi/quote/v1/ticker/price" // charts // https://finviz.com/crypto_charts.ashx?t=ALL&tf=h1 if (message.Text == "/daily_repo@HBTC_RU_BOT") { try { System.Net.WebClient wc1 = new System.Net.WebClient(); String price_Responsehbc = wc1.DownloadString("https://api.hbtc.com/openapi/quote/v1/ticker/price"); String hbc_price1 = System.Text.RegularExpressions.Regex.Match(price_Responsehbc, @"HBCUSDT""+,""price"":""+[0-9]+.[0-9]+").Groups[0].Value; String hbc_price = System.Text.RegularExpressions.Regex.Match(hbc_price1, @"[0-9]+.[0-9]+").Groups[0].Value; System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://www.hbtc.com/api/v1/hobbit/repurchase/info"); String Distributed1 = System.Text.RegularExpressions.Regex.Match(price_Response, @"allocated"":""+[0-9]+.[0-9][0-9]").Groups[0].Value; String Distributed = System.Text.RegularExpressions.Regex.Match(Distributed1, @"[0-9]+.[0-9][0-9]").Groups[0].Value; System.Net.WebClient wc2 = new System.Net.WebClient(); String LatestPricefor10xPE_Response = wc2.DownloadString("https://www.hbtc.com/api/v1/hobbit/repurchase/info"); String LatestPricefor10xPE1 = System.Text.RegularExpressions.Regex.Match(LatestPricefor10xPE_Response, @"tenTimesPrice"":""+[0-9]+.[0-9][0-9]").Groups[0].Value; String LatestPricefor10xPE = System.Text.RegularExpressions.Regex.Match(LatestPricefor10xPE1, @"[0-9]+.[0-9][0-9]").Groups[0].Value; System.Net.WebClient wc3 = new System.Net.WebClient(); String LatestPricefor5xPE_Response = wc3.DownloadString("https://www.hbtc.com/api/v1/hobbit/repurchase/info"); String LatestPricefor5xPE1 = System.Text.RegularExpressions.Regex.Match(LatestPricefor5xPE_Response, @"fiveTimesPrice"":""+[0-9]+.[0-9][0-9]").Groups[0].Value; String LatestPricefor5xPE = System.Text.RegularExpressions.Regex.Match(LatestPricefor5xPE1, @"[0-9]+.[0-9][0-9]").Groups[0].Value; System.Net.WebClient wc4 = new System.Net.WebClient(); String LockedVolume_Response = wc4.DownloadString("https://www.hbtc.com/api/v1/hobbit/repurchase/info"); String LockedVolume1 = System.Text.RegularExpressions.Regex.Match(LockedVolume_Response, @"lockTotal"":""+[0-9]+").Groups[0].Value; String LockedVolume = System.Text.RegularExpressions.Regex.Match(LockedVolume1, @"[0-9]+").Groups[0].Value; CultureInfo temp_culture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); double dist_usdt = Convert.ToDouble(Convert.ToString(hbc_price)) * Convert.ToDouble(Convert.ToString(Distributed)); decimal dist_usdt_out = Convert.ToDecimal(dist_usdt.ToString("0.##")); var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти на hbtc.com", CallbackData = "demo", Url = "https://www.hbtc.com/captain/daily_repo" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); await Bot.SendTextMessageAsync(message.Chat.Id, "<code>Accu.to be Distributed: " + Distributed + " HBC" + "\n" + "Accu.to be Distributed: ~ " + dist_usdt_out + " USDT" + "\n" + "Latest Price 10xPE: " + LatestPricefor10xPE + " USDT \n" + "Latest Price 5PE: " + LatestPricefor5xPE + " USDT \n" + "LockedVolume: " + LockedVolume + " HBC</code>", ParseMode.Html, false, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Text == "/hbc_usdt@HBTC_RU_BOT") { try { System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://api.hbtc.com/openapi/quote/v1/ticker/price"); String hbc_price1 = System.Text.RegularExpressions.Regex.Match(price_Response, @"HBCUSDT""+,""price"":""+[0-9]+.[0-9]+").Groups[0].Value; String hbc_price = System.Text.RegularExpressions.Regex.Match(hbc_price1, @"[0-9]+.[0-9]+").Groups[0].Value; var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти к паре HBC/USDT", CallbackData = "demo", Url = "https://www.hbtc.co/exchange/HBC/USDT" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); await Bot.SendTextMessageAsync(message.Chat.Id, "<code><b>HBC/USDT</b>" + "\n" + "Цена:" + hbc_price + " USDT</code>", ParseMode.Html, false, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Text == "/btc_usdt@HBTC_RU_BOT") { try { //new site api //[0-9]+.[0-9]+(?=,"lastVolume") System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://finviz.com/api/quote.ashx?&ticker=BTCUSD&instrument=crypto&timeframe=i5"); String btc_price = System.Text.RegularExpressions.Regex.Match(price_Response, @"[0-9]+.[0-9]+(?=,""lastVolume"")").Groups[0].Value; //https://finviz.com/api/quote.ashx?&ticker=BTCUSD&instrument=crypto&timeframe=i5 //htbc site api /* * System.Net.WebClient wc = new System.Net.WebClient(); * String price_Response = wc.DownloadString("https://api.hbtc.com/openapi/quote/v1/ticker/price"); * String btc_price1 = System.Text.RegularExpressions.Regex.Match(price_Response, @"BTCUSDT""+,""price"":""+[0-9]+.[0-9]+").Groups[0].Value; * String btc_price = System.Text.RegularExpressions.Regex.Match(btc_price1, @"[0-9]+.[0-9]+").Groups[0].Value; */ System.Net.WebClient wc1 = new System.Net.WebClient(); String rev_Response = wc1.DownloadString("https://finviz.com/crypto_charts.ashx"); String rev_1 = System.Text.RegularExpressions.Regex.Match(rev_Response, @"&rev=[0-9]+").Groups[0].Value; String rev = System.Text.RegularExpressions.Regex.Match(rev_1, @"[0-9]+").Groups[0].Value; //photo rev // [0-9]+(?=" width="320") var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти к паре BTC/USDT", CallbackData = "demo", Url = "https://www.hbtc.co/exchange/BTC/USDT" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); //await Bot.SendTextMessageAsync(message.Chat.Id, "<code><b>BTC/USDT</b>" + "\n" + "Цена:" + btc_price + " USDT</code>", ParseMode.Html, false, false, 0, inlineKeyboardMarkup); await Bot.SendPhotoAsync(message.Chat.Id, photo : "https://finviz.com/fx_image.ashx?btcusd_m5_s.png&rev=" + rev, " <code><b>BTC/USDT</b>" + "\n" + "Цена:" + btc_price + " USDT</code>", ParseMode.Html, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Text == "/bch_usdt@HBTC_RU_BOT") { try { //new site api //[0-9]+.[0-9]+(?=,"lastVolume") System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://finviz.com/api/quote.ashx?&ticker=BCHUSD&instrument=crypto&timeframe=i5"); String BCH_price = System.Text.RegularExpressions.Regex.Match(price_Response, @"[0-9]+.[0-9]+(?=,""lastVolume"")").Groups[0].Value; //htbc site api /* * System.Net.WebClient wc = new System.Net.WebClient(); * String price_Response = wc.DownloadString("https://api.hbtc.com/openapi/quote/v1/ticker/price"); * String btc_price1 = System.Text.RegularExpressions.Regex.Match(price_Response, @"BTCUSDT""+,""price"":""+[0-9]+.[0-9]+").Groups[0].Value; * String btc_price = System.Text.RegularExpressions.Regex.Match(btc_price1, @"[0-9]+.[0-9]+").Groups[0].Value; */ System.Net.WebClient wc1 = new System.Net.WebClient(); String rev_Response = wc1.DownloadString("https://finviz.com/crypto_charts.ashx"); String rev_1 = System.Text.RegularExpressions.Regex.Match(rev_Response, @"&rev=[0-9]+").Groups[0].Value; String rev = System.Text.RegularExpressions.Regex.Match(rev_1, @"[0-9]+").Groups[0].Value; //photo rev // [0-9]+(?=" width="320") var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти к паре BCH/USDT", CallbackData = "demo", Url = "https://www.hbtc.co/exchange/BCH/USDT" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); //await Bot.SendTextMessageAsync(message.Chat.Id, "<code><b>BTC/USDT</b>" + "\n" + "Цена:" + btc_price + " USDT</code>", ParseMode.Html, false, false, 0, inlineKeyboardMarkup); await Bot.SendPhotoAsync(message.Chat.Id, photo : "https://finviz.com/fx_image.ashx?bchusd_m5_s.png&rev=" + rev, " <code><b>BCH/USDT</b>" + "\n" + "Цена:" + BCH_price + " USDT</code>", ParseMode.Html, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Text == "/eth_usdt@HBTC_RU_BOT") { try { System.Net.WebClient wc1 = new System.Net.WebClient(); String rev_Response = wc1.DownloadString("https://finviz.com/crypto_charts.ashx"); String rev_1 = System.Text.RegularExpressions.Regex.Match(rev_Response, @"&rev=[0-9]+").Groups[0].Value; String rev = System.Text.RegularExpressions.Regex.Match(rev_1, @"[0-9]+").Groups[0].Value; System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://finviz.com/api/quote.ashx?&ticker=ETHUSD&instrument=crypto&timeframe=i5"); String ETH_price = System.Text.RegularExpressions.Regex.Match(price_Response, @"[0-9]+.[0-9]+(?=,""lastVolume"")").Groups[0].Value; //https://finviz.com/api/quote.ashx?&ticker=BTCUSD&instrument=crypto&timeframe=i5 var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти к паре ETH/USDT", CallbackData = "demo", Url = "https://www.hbtc.co/exchange/ETH/USDT" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); await Bot.SendPhotoAsync(message.Chat.Id, photo : "https://finviz.com/fx_image.ashx?ethusd_m5_s.png&rev=" + rev, " <code><b>ETH/USDT</b>" + "\n" + "Цена:" + ETH_price + " USDT</code>", ParseMode.Html, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Text == "/ltc_usdt@HBTC_RU_BOT") { try { System.Net.WebClient wc1 = new System.Net.WebClient(); String rev_Response = wc1.DownloadString("https://finviz.com/crypto_charts.ashx"); String rev_1 = System.Text.RegularExpressions.Regex.Match(rev_Response, @"&rev=[0-9]+").Groups[0].Value; String rev = System.Text.RegularExpressions.Regex.Match(rev_1, @"[0-9]+").Groups[0].Value; System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://finviz.com/api/quote.ashx?&ticker=LTCUSD&instrument=crypto&timeframe=i5"); String ltc_price = System.Text.RegularExpressions.Regex.Match(price_Response, @"[0-9]+.[0-9]+(?=,""lastVolume"")").Groups[0].Value; var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти к паре LTC/USDT", CallbackData = "demo", Url = "https://www.hbtc.co/exchange/LTC/USDT" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); await Bot.SendPhotoAsync(message.Chat.Id, photo : "https://finviz.com/fx_image.ashx?ltcusd_m5_s.png&rev=" + rev, " <code><b>LTC/USDT</b>" + "\n" + "Цена:" + ltc_price + " USDT</code>", ParseMode.Html, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Text == "/eos_usdt@HBTC_RU_BOT") { try { System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://api.hbtc.com/openapi/quote/v1/ticker/price"); String EOS_price1 = System.Text.RegularExpressions.Regex.Match(price_Response, @"EOSUSDT""+,""price"":""+[0-9]+.[0-9]+").Groups[0].Value; String EOS_price = System.Text.RegularExpressions.Regex.Match(EOS_price1, @"[0-9]+.[0-9]+").Groups[0].Value; var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти к паре EOS/USDT", CallbackData = "demo", Url = "https://www.hbtc.co/exchange/EOS/USDT" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); await Bot.SendTextMessageAsync(message.Chat.Id, "<code><b>EOS/USDT</b>" + "\n" + "Цена:" + EOS_price + " USDT</code>", ParseMode.Html, false, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Text == "/xrp_usdt@HBTC_RU_BOT") { try { System.Net.WebClient wc1 = new System.Net.WebClient(); String rev_Response = wc1.DownloadString("https://finviz.com/crypto_charts.ashx"); String rev_1 = System.Text.RegularExpressions.Regex.Match(rev_Response, @"&rev=[0-9]+").Groups[0].Value; String rev = System.Text.RegularExpressions.Regex.Match(rev_1, @"[0-9]+").Groups[0].Value; System.Net.WebClient wc = new System.Net.WebClient(); String price_Response = wc.DownloadString("https://finviz.com/api/quote.ashx?&ticker=XRPUSD&instrument=crypto&timeframe=i5"); String xrp_price = System.Text.RegularExpressions.Regex.Match(price_Response, @"[0-9]+.[0-9]+(?=,""lastVolume"")").Groups[0].Value; var inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { new [] { new InlineKeyboardButton { Text = "Перейти к паре XRP/USDT", CallbackData = "demo", Url = "https://www.hbtc.co/exchange/XRP/USDT" } } }); await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); await Bot.SendPhotoAsync(message.Chat.Id, photo : "https://finviz.com/fx_image.ashx?xrpusd_m5_s.png&rev=" + rev, " <code><b>XRP/USDT</b>" + "\n" + "Цена:" + xrp_price + " USDT</code>", ParseMode.Html, false, 0, inlineKeyboardMarkup); } catch { } } if (message.Type == MessageType.ChatMemberLeft) { try { await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); } catch { } return; } var entities = message.Entities.Where(t => t.Type == MessageEntityType.Url || t.Type == MessageEntityType.Mention); foreach (var entity in entities) { if (entity.Type == MessageEntityType.Url) { try { //40103694 - @off_fov //571522545 - @ProAggressive //320968789 - @timcheg1 //273228404 - @hydranik //435567580 - Никита //352345393 - @i_am_zaytsev //430153320 - @KingOfMlnD //579784 - @kamiyar //536915847 - @m1Bean //460657014 - @DenisSenatorov if (message.From.Username == @"off_fov" || message.From.Username == @"bar1nn" || message.From.Username == @"doretos" || message.From.Username == @"ProAggressive" || message.From.Username == @"Mira_miranda") { return; } else { await Bot.DeleteMessageAsync(message.Chat.Id, message.MessageId); if (update.Message.From.Username != null) { await Bot.SendTextMessageAsync(message.Chat.Id, "@" + message.From.Username + ", Ссылки запрещены!"); return; } else { await Bot.SendTextMessageAsync(message.Chat.Id, message.From.FirstName + ", Ссылки запрещены!"); return; } } } catch { } return; } } } catch { } }; Bot.StartReceiving(); // запускаем прием обновлений } } catch (Telegram.Bot.Exceptions.ApiRequestException ex) { Console.WriteLine(ex.Message); // если ключ не подошел - пишем об этом в консоль отладки } }