public MainWindow() { InitializeComponent(); songRequest = new SongRequest(this); youtubePlayer = new YoutubePlayer(this); configWindow = new ConfigurationWindow(this); BotHelper = new BotHelper(configWindow.txtIRCChannel.Text, configWindow.txtIRCOAuth.Text); BotHelperThread = new Thread(new ThreadStart(BotHelper.Run)); isRunning = false; }
public async void Execute() { var email = _message.Text; if (!IsEmailValid(email)) { await _botClient.SendTextMessageAsync(_chatId, MessageFactory.WrongEMailMessage); return; } await MongoDBHelper.SaveEmail(_chatId, email); await _botClient.SendTextMessageAsync(_chatId, MessageFactory.AskProfessionMessage, replyMarkup : BotHelper.GetKeyboardForProfession()); }
// Check if somebody got an instant promotion, because that window will be blocking the bot even after a restart public static bool checkInstantPromo() { Bitmap button_ok = BotHelper.getResourceByName("button_ok"); Helper.BotHelper.Log("Instant Promo Check", true, true); Point okPoint = ImageRecognition.getPictureLocation(comparePic, button_ok); if (okPoint != pNull) { ADBHelper.simulateClick(ImageRecognition.getRandomLoc(okPoint, button_ok)); BotHelper.Log("Someone got instant promoted."); BotHelper.randomDelay(1200, 100); return(true); } return(false); }
public IActionResult MarketChartData() { var model = new CashChartDataViewModel(Framework.Context.Project); var botUsers = BotHelper.GetCalculatedBotProject(Framework.Context.Project, Framework.Context.IterationNumber).Webshops.Sum(w => w.UserCount); var playerUsers = Framework.Context.Project.Webshops.Sum(w => w.UserCount); var res = new[] { new { label = "You", data = Math.Truncate(playerUsers) }, new { label = "Bot", data = Math.Truncate(botUsers) }, new { label = "Available market", data = Math.Truncate((playerUsers + botUsers) / 3) } }; return(Json(res)); }
public void tryCastSpellToCreep(int indice) { Point go = ImageValues.EnemyCreepPosition(); if (go.X == 0 && go.Y == 0) { return; } InputHelper.MoveMouse(go.X + 28, go.Y + 42); string key = "D" + indice; InputHelper.PressKey(key.ToString()); BotHelper.Wait(65); }
public void waitProcessOpen(string processName) { while (!Interop.IsProcessOpen(processName)) { BotHelper.Wait(1000); /*if(processName == "League of Legends") { * _outActualTime++; * * if(_outActualTime == _outMaxTime) * { * Logger.Write("Someone picked your champ... ", MessageState.WARNING); * } * }*/ } }
public void MoveAwayFromCreep() { Point go = ImageValues.EnemyCreepPosition(); if (go.X == 0 && go.Y == 0) { return; } //InputHelper.RightClick(770, 690); //680.680 InputHelper.RightClick(780, 600); BotHelper.Wait(1100); // depends on attack speed //InputHelper.MoveMouse(go.X + 50, go.Y + 100); InputHelper.MoveMouse(970, 540); InputHelper.PressKey("A"); }
public void tryCastSpellToEnemyChampion(int indice) { Point go = ImageValues.EnemyChampion(); if (go.X == 0 && go.Y == 0) { return; } InputHelper.MoveMouse(go.X + 39, go.Y + 129); string key = "D" + indice; InputHelper.PressKey(key.ToString()); BotHelper.Wait(50); }
public void tryCastSpellToEnemyCreep(int indice) { Point go = ImageValues.EnemyCreepPosition(); if (go.X == 0 && go.Y == 0) { return; } InputHelper.MoveMouse(go.X + 39, go.Y + 129); BotHelper.Wait(50); InputHelper.PressKey(indice.ToString()); BotHelper.Wait(50); }
public void cast() { Point go = ImageValues.EnemyChampion(); if (go.X == 0 && go.Y == 0) { return; } InputHelper.MoveMouse(go.X + 39, go.Y + 129); string key = "D" + this.spell; InputHelper.PressKey(key.ToString()); BotHelper.Wait(50); }
public void tryCastSpellToCreep(String spell) { Point go = ImageValues.EnemyCreepPosition(); if (go.X == 0 && go.Y == 0) { return; } InputHelper.MoveMouse(go.X + 28, go.Y + 42); BotHelper.Wait(50); InputHelper.PressKey(spell); BotHelper.Wait(65); }
public void talkInChampSelect(string message) { InputHelper.LeftClick(390, 940, 200); BotHelper.Wait(100); foreach (var character in message) { Keys key = KeyboardMapper.GetKey(character); Keyboard.KeyPress(key, 150); BotHelper.Wait(100); } BotHelper.InputIdle(); Keyboard.KeyPress(Keys.Enter, 150); BotHelper.InputIdle(); }
public void talkInGame(string message) { Keyboard.KeyPress(Keys.Enter, 150); BotHelper.Wait(100); foreach (var character in message) { Keys key = KeyboardMapper.GetKey(character); Keyboard.KeyPress(key, 150); BotHelper.Wait(100); } BotHelper.InputIdle(); Keyboard.KeyPress(Keys.Enter, 150); BotHelper.InputIdle(); }
//Attack Logic public static void doLogic() { if (logicErrors >= 5) { BotHelper.Log("Too many errors. Restarting CATS."); ADBHelper.stopCATS(); BotHelper.randomDelay(1000, 5); ADBHelper.startCATS(); BotHelper.Log("Waiting for CATS to restart. Waiting 30s."); BotHelper.randomDelay(30000, 5); } if (searchDuell()) { if (waitDuell()) { if (startDuell()) { BotHelper.Log("AttackLogic successfully completed."); logicErrors = 0; } else { BotHelper.Log("AttackLogic failed during startDuell"); logicErrors++; } } else { BotHelper.Log("AttackLogic failed during waitDUell"); logicErrors++; } } else { BotHelper.Log("AttackLogic failed during searchDuell"); BotHelper.Log("Please make sure that your games language is set to English and that MEmu is set to 1280x720 in windowed mode."); logicErrors++; Thread.Sleep(5000); //give the user time to see this message :P } if (logicErrors > 0) { BotHelper.Log("We had " + logicErrors + " errors in a row during AttackLogic, restarting at 5 errors"); } }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("Vault.json"); IConfiguration config = new ConfigurationBuilder() .AddJsonFile("Vault.json", false, true) .Build(); Vault.Load(config); BotHelper.Configure(); BotHelper.Start(); Console.ReadLine(); }
public void waitProcessOpen(string processName, Action timeoutCallback = null, int timeout = 20) { Stopwatch st = Stopwatch.StartNew(); while (!Interop.IsProcessOpen(processName)) { if (timeoutCallback != null) { if (st.Elapsed.TotalSeconds > timeout) { timeoutCallback(); return; } } BotHelper.Wait(1000); } }
// Try to find the "Quick Fight" button and click on it. public static bool searchDuell() { BotHelper.Log("Attempting to press the Duell button"); if (ImageRecognition.getPictureLocation(Properties.Resources.button_fight, BotHelper.memu) != pNull) { Point dbgPoint = ImageRecognition.getPictureLocation(Properties.Resources.button_fight, BotHelper.memu); BotHelper.Log("Button found! FeelsGoodMan."); BotHelper.Log("Button found at: X = " + dbgPoint.X + "; Y = " + dbgPoint.Y, true, true); ClickOnPointTool.ClickOnPoint(BotHelper.memu, ImageRecognition.getRandomLoc(Properties.Resources.button_fight, BotHelper.memu)); return(true); } else { BotHelper.Log("Button not found! FeelsBadMan."); return(false); } }
private static Point getClosestChest() { Point chestArrow = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("arrow_chest"), 0.791f).FirstOrDefault(); List <Point> regularBoxes = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_regular")); List <Point> superBoxes = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_super")); List <Point> sponsorBox = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_sponsor")); List <Point> allChests = new List <Point>(); allChests.AddRange(regularBoxes); allChests.AddRange(superBoxes); allChests.AddRange(sponsorBox); // Return the closest chest that's below the arrow return(allChests.Where(pt => pt.Y > chestArrow.Y).GetClosestPoint(chestArrow)); }
/// <summary> /// Main Telegram Bot Task /// <para>Telegram messages are requested from the Telegram service and processed accordingly. /// Messages are filtered on text-messages only and passed to the BotHelper class for further dispatching</para> /// </summary> /// <returns></returns> static async Task Run() { BotHelper BotHelper = new BotHelper(); User currentBot = await BotHelper.GetBot(); Config.Log($"Bot: {currentBot.Username} - Status Online..."); var offset = 0; while (true) { try { var updates = await BotHelper.GetUpdates(offset); foreach (var update in updates) { if (update.Message.Type == MessageType.TextMessage) { string username = update.Message.Chat.FirstName; if (update.Message.Chat.Type == ChatType.Group) { username = update.Message.From.FirstName; Config.Log($"Group: {update.Message.Chat.Title} User: {username} Message: {update.Message.Text}"); } else { Config.Log($"User: {username} Message: {update.Message.Text}"); } await BotHelper.ProcessCommand(update.Message.Chat.Id, update.Message.Text, username); } offset = update.Id + 1; } await Task.Delay(1000); } catch (Exception ex) { Config.Log("Process stopped!"); Config.Log($"Error Message: {ex.Message}"); Restart(); } } }
static int PerformSearchCrew(SearchCrew opts) { var botHelper = new BotHelper("https://datacore.app/", System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "..", "..", "data")); botHelper.ParseData(); var result = botHelper.SearchCrew(opts.Term); if (result.Count == 0) { Console.WriteLine("Not found"); } else { Console.WriteLine($"Found: {string.Join(',', result.Select(r => r.name))}"); } return(0); }
private async Task SendMessageIfDefined(string id, IEnumerable <string> messages) { if (!messages.Any()) { return; } var clients = _repository.GetServerClients(id); if (clients.Count == 0) { throw new ArgumentException($"There are no clients for id: {id}"); } foreach (var client in clients) { await BotHelper.SendMessageToClient(client, string.Join(Environment.NewLine + Environment.NewLine, messages)); } }
public static bool checkForChestInForeground() { Bitmap regChest = BotHelper.getResourceByName("label_regularbox"); Bitmap supChest = BotHelper.getResourceByName("label_super_box"); Bitmap legChest = BotHelper.getResourceByName("label_legendary_box"); Point pRegChest = ImageRecognition.getPictureLocation(comparePic, regChest); Point pSupChest = ImageRecognition.getPictureLocation(comparePic, supChest); Point pLegChest = ImageRecognition.getPictureLocation(comparePic, legChest); if (pRegChest != pNull || pSupChest != pNull || pLegChest != pNull) { ChestLogic.openChest(); return(true); } return(false); }
public void moveAwayFromEnemy() { Point go = ImageValues.EnemyChampion(); if (go.X == 0 && go.Y == 0) { return; } Random r = new Random(); InputHelper.MoveMouse(go.X + 45, go.Y + 100); InputHelper.PressKey("A"); BotHelper.Wait(r.Next(866, 1233)); //PLAYER POSITION UPDATER updatePlayerPosition(); //while (playerHasRange("enemy")) //{ //if (towerHealthBarFound()) // break; //if (enemyTowerHealthBarFound2()) // break; //if (!AllyMinion.isThereAnAllyCreep2()) // break; //if (!isPlayerBotInScreen()) // break; go = ImageValues.EnemyChampion(); //if (go.X == 0 && go.Y == 0) // break; InputHelper.MoveMouse(go.X + 45, go.Y + 100); InputHelper.PressKey("A"); //} InputHelper.RightClick(780, 600); BotHelper.Wait(r.Next(222, 433)); }
public bool playerHasRange(string type) { Point go; double positionBuffer = 1.2; updatePlayerPosition(); switch (type) { case "enemy": go = ImageValues.EnemyChampion(); if (go.X != 0 && go.Y != 0) { double dist = Math.Abs(Math.Sqrt(Math.Pow(PlayerPosition.X - go.X, 2) + Math.Pow(PlayerPosition.Y - go.Y, 2))); BotHelper.Log("Enemy Champion dist: " + dist + " Champion range modifer: " + game.attackRange * positionBuffer); if (dist >= game.attackRange * positionBuffer) { return(true); } } break; case "creep": go = ImageValues.EnemyCreepPosition(); if (go.X != 0 && go.Y != 0) { double dist = Math.Abs(Math.Sqrt(Math.Pow(PlayerPosition.X - go.X, 2) + Math.Pow(PlayerPosition.Y - go.Y, 2))); BotHelper.Log("Enemy creep dist: " + dist + " Champion range modifer: " + game.attackRange * positionBuffer); if (dist >= game.attackRange * positionBuffer) { //BotHelper.Log("Enemy creep dist: " + dist + " Champion range modifer: " + game.attackRange * positionBuffer); return(true); } else { BotHelper.Log("Too Close! Enemy creep dist: " + dist + " Champion range modifer: " + game.attackRange * positionBuffer); } } break; } return(false); }
public override async Task Execute(Message message, ITelegramBotClient client, IReminderStore reminderStore, CallbackQuery callbackQuery = null) { var chatId = message.Chat.Id; var text = message.Text.Remove(0, Name.Length).Trim(); if (!string.IsNullOrEmpty(text)) { var date = BotHelper.AnalizeStringToDate(text); reminderStore.Set(new Reminder(text, date)); await client.SendTextMessageAsync(chatId, $"Я запомню, дата установлена: {date}"); } else { await client.SendTextMessageAsync(chatId, "введи напомнить + свой текст с временем в формате 00:00" + "\nНапример: напомнить сходить в барбершоп в 18:00"); } }
public async Task <ActionResult> Post([FromBody] Notification request) { var testData = new Notification() { Bank = "Тинькофф", Id = 1, CardNumber = "123456", DateRequest = DateTime.Now, Sum = 100 }; try { //var note = new GetRequest(telegramBot, testData); var test = new BotHelper(telegramBot); test.SendMessage(testData); return(Ok("Сообщение отправлено")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
//returns 1 for win, 2 for loss and 0 for error private static int checkWin() { Bitmap img = ImageRecognition.CaptureApplication(); Bitmap label_victory = BotHelper.getResourceByName("label_victory"); Bitmap label_defeat = BotHelper.getResourceByName("label_defeat"); Point win = ImageRecognition.GetSubPositions(img, label_victory).FirstOrDefault(); Point defeat = ImageRecognition.GetSubPositions(img, label_defeat).FirstOrDefault(); if (win.X != 0 && win.Y != 0) { return(1); } else if (defeat.X != 0 && defeat.Y != 0) { return(2); } return(0); }
public void doLoop() { BotHelper.randomDelay(3000, 500); BotHelper.Log("(Re-)Starting main loop."); BotLogics.ClearScreenLogic.doLogic(); if (chkAutoReconnect.Checked) { BotLogics.ReconnectLogic.doLogic(); } if (chkUseChestLogic.Checked) { BotLogics.ChestLogic.doLogic(); // uncomment this line to test the chest opener. Please report any false-positives. } BotLogics.AttackLogic.doLogic(); doLoop(); }
public void moveNearestBotlaneAllyTower() { //Primera torreta aliada con placas aun viva. if (ImageHelper.GetColor(1410, 924) == "#1C4F5D")//ALIVE: #1B4D5A - 1422,904 (buscar color) { InputHelper.RightClick(1410, 911); BotHelper.InputIdle(); return; } if (ImageHelper.GetColor(1387, 834) == "#3592B1") { InputHelper.RightClick(1410, 911); BotHelper.InputIdle(); return; } //Primera torreta aliada sin placas if (ImageHelper.GetColor(1411, 922) == "#2A788D")//ALIVE: #1B4D5A - 1422,904 (buscar color) { InputHelper.RightClick(1410, 911); BotHelper.InputIdle(); return; } //Segunda torreta aliada sin placas if (ImageHelper.GetColor(1366, 916) == "#328AA8")//ALIVE: #1B4D5A - 1422,904 (buscar color) { InputHelper.RightClick(1366, 916); BotHelper.InputIdle(); return; } //Tercera torreta aliada sin placas if (ImageHelper.GetColor(1335, 917) == "#2C7B92")//ALIVE: #1B4D5A - 1422,904 (buscar color) { InputHelper.RightClick(1335, 916); BotHelper.InputIdle(); return; } //Todas las torretas han caido. Pues al nexo. InputHelper.RightClick(1308, 905); BotHelper.InputIdle(); }
//Check for the skip button. If it's there, an opponent has been found. public static bool waitDuell() { BotHelper.Log("Waiting for the duell to start...."); int checks = 0; do { BotHelper.Log(" " + checks, false); Thread.Sleep(100); checks++; } while (ImageRecognition.getPictureLocation(Properties.Resources.button_skip, BotHelper.memu) == pNull && checks <= 55); if (checks >= 55) { BotHelper.Log("Oops, we timed out."); return(false); } BotHelper.randomDelay(500, 50); return(true); }
/// <summary> /// Checks whether the END key is down to turn the bot off. /// </summary> private void PanicKeyThread() { CrossThreadAppendLog("Panic key thread started\n"); while (true) { if (BotHelper.IsKeyDown(System.Windows.Forms.Keys.End)) { ToggleBotStatus(); } if (IsStopped()) { break; } Thread.Sleep(20); } CrossThreadAppendLog("Panic key thread stopped\n"); }