示例#1
1
        public TelegramService(string apiKey, ISession session)
        {
            this.bot = new TelegramBotClient(apiKey);
            this.session = session;

            var me = bot.GetMeAsync().Result;

            bot.OnMessage += OnTelegramMessageReceived;
            bot.StartReceiving();

            this.session.EventDispatcher.Send(new NoticeEvent {Message = "Using TelegramAPI with " + me.Username});
        }
示例#2
1
        public TelegramService(string apiKey, ISession session)
        {
            try
            {
                _bot = new TelegramBotClient(apiKey);
                _session = session;

                var me = _bot.GetMeAsync().Result;

                _bot.OnMessage += OnTelegramMessageReceived;
                _bot.StartReceiving();

                _session.EventDispatcher.Send(new NoticeEvent {Message = "Using TelegramAPI with " + me.Username});
            }
            catch (Exception)
            {
                _session.EventDispatcher.Send(new ErrorEvent { Message = "Unkown Telegram Error occured. "});
            }
        }
示例#3
0
 private void button1_Click(object sender, EventArgs e)
 {
     BOT            = new Telegram.Bot.TelegramBotClient("744578703:AAFel2eXEWWYrsiplEPhxgxNCd2BSLumYmQ");
     BOT.OnMessage += BotOnMessageReceived;
     BOT.StartReceiving();
     button1.Enabled = false;
 }
示例#4
0
        private TelegramBotClient BuildBot()
        {
            var bot = new Telegram.Bot.TelegramBotClient("340012648:AAF1bURuuTS7Dce5iDfkQrINRDHNMftSSeo");

            bot.OnMessage += BotOnMessageReceived;
            bot.StartReceiving();
            return(bot);
        }
 private void StartBot(object sender, RoutedEventArgs e)
 {
     if (TokenLabel.Content.Equals("Token received"))
     {
         TokenLabel.Content = "Bot alive";
     }
     BOT            = new Telegram.Bot.TelegramBotClient(Token);
     BOT.OnMessage += BotOnMessageReceived;
     BOT.StartReceiving(new UpdateType[] { UpdateType.Message });
 }
示例#6
0
 public bool Act()
 {
     try
     {
         botik.StartReceiving();
     }
     catch (Exception e) {
         return(false);
     }
     return(true);
 }
        public void Startup()
        {
            RequestQueue.Start();
            ResponseQueue.Start();

            try
            {
                TheClient.StartReceiving();
            }
            catch (Exception)
            {
            }
        }
示例#8
0
        public TelegramConnector()
        {
            botClient = new Telegram.Bot.TelegramBotClient("524727579:AAHZaFNr3S1vUfuPy-wZEIGO3-WxQWodL5s");
            var me = botClient.GetMeAsync();

            Console.WriteLine("Api for bot: " + me.Result.FirstName + " - was connected");
            Console.WriteLine("Connected to: " + botClient.GetChatAsync(chatId).Result.Title + "chat");

            botClient.OnMessage += onMessage;


            botClient.StartReceiving(Array.Empty <UpdateType>());
            Thread.Sleep(2000);
        }
示例#9
0
        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();
        }
示例#10
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

            json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All;

            //ModelBinders.Binders.Add(typeof(VmParticipantRule), new ParticipantRuleModelBinder());

            Bot.OnMessage += Bot_OnMessage;
            Bot.StartReceiving();
        }
示例#11
0
        public TelegramManager(AppDbContext dbContext, ITaskRepository taskRepository,
                               IExecutorRepository executorRepository)
        {
            TelegramSettings telegramSettings = new TelegramSettings {
                APIKey = "1013744878:AAF5qFktlgyBpXeVp-KXpWyb4dnTqUbSPN4"
            };

            _botClient = new Telegram.Bot.TelegramBotClient(telegramSettings.APIKey);
            NLog.LogManager.GetCurrentClassLogger().Info($"Telegram bot created:{telegramSettings.APIKey}");
            _taskRepository     = taskRepository;
            _executorRepository = executorRepository;
            _dbContext          = dbContext;

            _botClient.OnCallbackQuery       += _botClient_OnCallbackQuery;
            _botClient.OnReceiveError        += _botClient_OnReceiveError;
            _botClient.OnReceiveGeneralError += _botClient_OnReceiveGeneralError;
            _botClient.OnMessage             += _botClient_OnMessage;
            _botClient.OnInlineResultChosen  += _botClient_OnInlineResultChosen;
            _botClient.StartReceiving(Array.Empty <UpdateType>());
        }
示例#12
0
        static void Main(string[] args)
        {
            // 透過SendTextMessageAsync來傳送訊息,傳入chanelid及要傳送的訊息
            //chanelId test
            Bot.SendTextMessageAsync(chanelId, "每5秒傳送一個訊息");
            Bot.SendTextMessageAsync(chanelId, "Mickey Mouse");

            var me = Bot.GetMeAsync().Result;

            Console.Title        = me.Username;
            Bot.OnMessage       += BotOnMessageEcho;
            Bot.OnMessageEdited += BotOnMessageEcho;

            /* Bot.OnCallbackQuery += BotOnCallbackQueryReceived;
             * Bot.OnReceiveError += BotOnReceiveError;*/
            Bot.StartReceiving(Array.Empty <UpdateType>());
            Console.WriteLine($"Start listening for @cutebaby0630_Bot");
            Console.ReadLine();
            Bot.StopReceiving();
        }
示例#13
0
        private void bnSearch_Click(object sender, EventArgs e)
        {
            if (txtAPIKey.Text == "")
            {
                return;
            }

            MessageBox.Show("This will start the Bot for 10 seconds and saves the chat id from the first message arrived.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);

            tmSearch.Enabled = true;
            bnSearch.Enabled = false;

            TelegramBotClient = new TelegramBotClient(txtAPIKey.Text);

            __cancellationTokenSource = new CancellationTokenSource();

            var receiverOptions = new ReceiverOptions
            {
                AllowedUpdates = { } // receive all update types
            };

            TelegramBotClient.StartReceiving(HandleUpdateAsync, HandleErrorAsync, receiverOptions, __cancellationTokenSource.Token);
        }
示例#14
0
        //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); // если ключ не подошел - пишем об этом в консоль отладки
            }
        }
示例#15
0
        }                                                                    //Пробрасываем признак работы бота.

        /// <summary>
        /// Запуск бота
        /// </summary>
        public void Start()
        {
            botWorker.OnMessage += BotLstner;
            botWorker.StartReceiving();
        }
示例#16
0
 public Task ConnectAsync()
 {
     _bot.StartReceiving();
     _active = true;
     return(Task.CompletedTask);
 }
示例#17
0
 public override void Start()
 {
     Running = true;
     TClient.StartReceiving();
 }
示例#18
0
 private void setTelegramEvent()
 {
     bot.OnMessage += Bot_OnMessage;
     bot.StartReceiving();
 }