Example #1
0
 public static async Task SendMessage(string chatid, string message)
 {
     try
     {
         var bot = new Telegram.Bot.TelegramBotClient("312420207:AAGnEn6CztWMs8ExE9L808M2ZXApqTS2yPA");
         await bot.SendTextMessageAsync(chatid, message);
     }
     catch (Exception ex)
     {
         Logger.Write("Telegram Nachricht Senden Fehlgeschlagen - Grund: " + ex.Message);
         if (OSystem.IsAvailableNetworkActive())
         {
         }
     }
 }
Example #2
0
        public static async Task <string> GetProxie()
        {
            if (CurrentProxy != null)
            {
                RemoveProxy();
            }

            Logger.Write("Get Proxy...", LogLevel.Debug);
            if (Tools.DictionaryIsNullOrEmpty(Proxielist))
            {
                Logger.Write("Proxy Liste ist Leer, hole neue Proxies von Website", LogLevel.Debug);
                Proxielist = Tools.DictionaryMerge(Proxielist, await DealReminderDe()).GroupBy(pair => pair.Key)
                             .Select(group => group.First())
                             .ToDictionary(pair => pair.Key, pair => pair.Value);
                if (Tools.DictionaryIsNullOrEmpty(Proxielist))
                {
                    Logger.Write("Keine Proxies gefunden. Checke Internetverbindung.", LogLevel.Debug);
                    if (OSystem.IsAvailableNetworkActive())
                    {
                    }
                    return(null);
                }
            }

            foreach (KeyValuePair <string, int> proxy in Proxielist)
            {
                Logger.Write(proxy.Key + " - Response Time: " + proxy.Value, LogLevel.Debug);
                if (proxy.Key == Proxielist.Keys.Last())
                {
                    Logger.Write("------", LogLevel.Debug);
                }
            }

            _proxiewithRepsonsetime.Clear();
            await Tools.ProcessParalell(Proxielist, CheckResponseTime, 10);

            Proxielist = _proxiewithRepsonsetime.Where(p => true).OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

            Logger.Write("Working Proxies: " + Proxielist.Count, LogLevel.Debug);
            Logger.Write("------", LogLevel.Debug);

            foreach (KeyValuePair <string, int> proxy in Proxielist)
            {
                Logger.Write(proxy.Key + " - Response Time: " + proxy.Value, LogLevel.Debug);
                if (proxy.Key == Proxielist.Keys.Last())
                {
                    Logger.Write("------", LogLevel.Debug);
                }
            }

            var result = !Tools.DictionaryIsNullOrEmpty(Proxielist) ? Proxielist.First().Key : null;

            Logger.Write("Proxie Ausgwählt: " + result, LogLevel.Debug);

            if (!Settings.Get <bool>("ProxyAlwaysActive") && result != null && RealIPnexttime < DateTime.Now)
            {
                RealIPnexttime = DateTime.Now.AddMinutes(15);
            }

            return(result);
        }
Example #3
0
        public static async Task SendFeedbackMessage(string subject, string message, string attachment = null)
        {
            Main mf = Application.OpenForms["Main"] as Main;

            if (mf == null)
            {
                return;
            }

            var bot = new Telegram.Bot.TelegramBotClient("397478316:AAFx_E18FZ5bxNdO-F3wQtbPcw7OlrPddfU");

            try
            {
                await bot.SendTextMessageAsync(251417296, subject + "\n\n" + message);

                if (!String.IsNullOrWhiteSpace(attachment))
                {
                    try
                    {
                        string file     = attachment;
                        var    fileName = file.Split('\\').Last();
                        using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            var fts = new FileToSend(fileName, fileStream);
                            if (System.Web.MimeMapping.GetMimeMapping(file).StartsWith("text/") || System.Web.MimeMapping.GetMimeMapping(file).StartsWith("application/"))
                            {
                                await bot.SendDocumentAsync(251417296, fts, subject);
                            }
                            if (System.Web.MimeMapping.GetMimeMapping(file).StartsWith("image/"))
                            {
                                await bot.SendPhotoAsync(251417296, fts, subject);
                            }
                            if (System.Web.MimeMapping.GetMimeMapping(file).StartsWith("video/"))
                            {
                                await bot.SendVideoAsync(251417296, fts);
                            }
                        }
                    }
                    catch (FileNotFoundException ex)
                    {
                        Logger.Write("Telegram Feedback Anhang Senden Fehlgeschlagen - Grund: " + ex.Message);
                        //Text Info Output
                    }
                }
                MetroMessageBox.Show(mf, "Dein Feedback wurde Erfolgreich verschickt ;-)", "Feedback Erfolgreich",
                                     MessageBoxButtons.OK, MessageBoxIcon.Question);

                mf.metroComboBox5.SelectedIndex = -1;
                mf.metroTextBox2.Clear();
                mf.metroTextBox3.Clear();
                mf.metroTextBox4.Clear();
                mf.metroTextBox11.Clear();
                mf.metroTextBox12.Clear();
            }
            catch (Exception ex)
            {
                Logger.Write("Telegram Feedback Nachricht Senden Fehlgeschlagen - Grund: " + ex.Message);
                if (OSystem.IsAvailableNetworkActive())
                {
                }
                MetroMessageBox.Show(mf,
                                     "Leider gab es ein Problem und dein Feedback konnte nicht erfolgreich verschickt werden." +
                                     Environment.NewLine + Environment.NewLine + "Bitte versuche es erneut oder Kontaktiere den Entwickler.",
                                     "Feedback Fehlgeschlagen", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }