Exemplo n.º 1
0
 public void ProcedureFactoryItem(int factorySize)
 {
     for (var i = 0; i < factorySize; i++)
     {
         touch.Swipe(Constants.GetPoint(Bot.Location.FactoryResource1), Constants.GetPoint(Bot.Location.CentreMap));
         BotApplication.Wait(100);
     }
 }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            BotApplication botApplication = db.BotApplications.Find(id);

            db.BotApplications.Remove(botApplication);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public void CollectFactoryItem(int factorySize)
 {
     for (var i = 0; i < factorySize; i++)
     {
         BotApplication.Wait(10);
         CheckReadyFactoryItemAndCollect(i);
         BotApplication.Wait(50);
     }
 }
Exemplo n.º 4
0
        // GET: Broadcast/Create
        public ActionResult Create(BotApplication botApplication)
        {
            TempData["AuthorizationToken"] = botApplication.BotAuthorizationTokenApi;
            ViewBag.BotId = botApplication.BotId;

            ViewBag.ContentTypeList = CreateContentTypeList();

            return(View());
        }
Exemplo n.º 5
0
        public void SellItems(int n = 0)
        {
            for (var i = 0; i < 5; i++)
            {
                touch.GotoTopLeft();
            }

            touch.GotoTradeDepot();
            BotApplication.Wait(500);

            if (CheckIfInTradeDepot())
            {
                // 409 305 x 150 px
                for (var i = 0; i < 8; i++)
                {
                    bool result = CreateSellItem(0, i);
                    if (!result)
                    {
                        break;
                    }
                }

                Bot.BotApplication.Wait(150);
                touch.Execute("input touchscreen swipe 923 300 384 300");
                //touch.Swipe(new Point(900, 300), new Point(900, 300), new Point(384, 300), 1, true);
                Bot.BotApplication.Wait(150);
                for (var i = 0; i < 8; i++)
                {
                    CreateSellItem(1, i);
                }

                //Bot.BotApplication.Wait(150);
                //touch.Swipe(new Point(923, 300), new Point(923, 300), new Point(384, 300), 1, true);
                //Bot.BotApplication.Wait(150);
                //for (var i = 0; i < 8; i++)
                //{
                //    CreateSellItem(1, i);

                //}


                //// Color c = touch.GetPixel(409,305);
                if (CheckIfInTradeDepot())
                {
                    touch.ClickAt(new Point(958, 135));
                }
                this.touch.GotoCenter();
            }
            //else {
            //    if(n<3)
            //    SellItems(n++);
            //}
        }
Exemplo n.º 6
0
        public ActionResult Edit([Bind(Include = "BotId,BotName,BotIdentifier,BotAccessToken")] BotApplication botApplication)
        {
            botApplication.BotAuthorizationTokenApi = GenerateAuthorizationToken(botApplication.BotIdentifier, botApplication.BotAccessToken);

            if (ModelState.IsValid)
            {
                db.Entry(botApplication).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(botApplication));
        }
Exemplo n.º 7
0
        private static void Main()
        {
            IServiceProvider serviceProvider = new ServiceCollection()
                                               .UseLogging()
                                               .UseConfiguration()
                                               .UseTelegramClient()
                                               .UseMongoDBStorages()
                                               .UseAuthentication()
                                               .UseMongoDBAuthentication <ApplicationUser, ApplicationUserFactory>()
                                               .UseHandlers()
                                               .BuildServiceProvider();

            BotApplication.Create(serviceProvider).StartAndWait();
        }
Exemplo n.º 8
0
        // GET: BotApplications/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BotApplication botApplication = db.BotApplications.Find(id);

            if (botApplication == null)
            {
                return(HttpNotFound());
            }

            return(View(botApplication));
        }
Exemplo n.º 9
0
        public static async Task Main(string[] args)
        {
            Trace.Listeners.Add(new ConsoleTraceListener {
                Filter = new EventTypeFilter(SourceLevels.Error)
            });
            Trace.Listeners.Add(new ConsoleTraceListener {
                Filter = new EventTypeFilter(SourceLevels.Information)
            });
            //Trace.Listeners.Add(..)

            Options options = null;

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(o => options = o);

            if (options.Console)
            {
                CmdApplication.Run(Array.Empty <string>());
            }
            else
            {
                await BotApplication.Run(Array.Empty <string>());
            }
        }
Exemplo n.º 10
0
        public async Task <ActionResult> Create(Broadcast collection)
        {
            BotApplication botApplication = db.BotApplications.Where(x => x.BotId == collection.BotId).FirstOrDefault();

            collection.BotApplication = botApplication;

            try
            {
                if (ModelState.IsValid)
                {
                    db.Broadcasts.Add(collection);
                    db.SaveChanges();

                    await SendMessage(collection);
                }
                //await ShowDistributionListAsync(botApplication.BotAuthorizationTokenApi);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Exemplo n.º 11
0
        public void CraftItem()
        {
            this.touch.GotoCenter();

            int cnt = 0;

            while (!CheckIfInFactory())
            {
                touch.ClickAt(Bot.Location.FirstStore);


                BotApplication.Wait(200);
                cnt++;
                if (cnt > 10)
                {
                    break;
                }
            }
            if (!CheckIfInFactory())
            {
                while (!CheckIfInFactory())
                {
                    touch.ClickAt(Bot.Location.SecondStore);


                    BotApplication.Wait(200);
                    cnt++;
                    if (cnt > 10)
                    {
                        break;
                    }
                }
            }
            if (!CheckIfInFactory())
            {
                return;
            }
            for (int i = 0; i < 4; i++) // number of store
            {
                for (int j = 0; j < 4; j++)
                {
                    touch.ClickAt(Bot.Location.CenterFactory);
                    Bot.BotApplication.Wait(100);
                }
                for (int j = 0; j < 2; j++)
                {
                    touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner1), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                    Bot.BotApplication.Wait(100);
                    // check if not enouch resource
                    //510 480
                    if (touch.CheckPixel(510, 480, Color.White, 10))
                    {
                        touch.ClickAt(new Point(510, 480));
                        Bot.BotApplication.Wait(200);
                        break;
                    }
                }

                /*
                 * for (int j = 0; j < 2; j++)
                 * {
                 *
                 *  touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner2), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                 *  Bot.BotApplication.Wait(100);
                 *  // check if not enouch resource
                 *  //510 480
                 *  if (touch.CheckPixel(510, 480, Color.White, 10))
                 *  {
                 *      touch.ClickAt(new Point(510, 480));
                 *      Bot.BotApplication.Wait(200);
                 *      break;
                 *  }
                 * }
                 * for (int j = 0; j < 2; j++)
                 * {
                 *
                 *  touch.Swipe(Constants.GetPoint(Bot.Location.ButtonLeftInner3), Constants.GetPoint(Bot.Location.CentreMap)); // procedure
                 *  Bot.BotApplication.Wait(100);
                 *  // check if not enouch resource
                 *  //510 480
                 *  if (touch.CheckPixel(510, 480, Color.White, 10))
                 *  {
                 *      touch.ClickAt(new Point(510, 480));
                 *      Bot.BotApplication.Wait(200);
                 *      break;
                 *  }
                 * }
                 */
                Bot.BotApplication.Wait(100);
                nextFactory();
                Bot.BotApplication.Wait(100);
            }
            if (CheckIfInFactory())
            {
                touch.sendRawEvent("1 1 1");
                touch.sendRawEvent("0 0 0");
                //touch.ClickAt(new Point(150, 150));

                /*
                 * /dev/input/event7: 0001 0001 00000001
                 * /dev/input/event7: 0000 0000 00000000
                 */
            }
        }
Exemplo n.º 12
0
        public void ProcedureItems()
        {
            this.touch.GotoCenter();
            Random       rnd   = new Random();
            List <Point> items = new List <Point>();

            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));

            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner2));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner2));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner2));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner2));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner1));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner2));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner2));
            items.Add(Constants.GetPoint(Bot.Location.ButtonLeftInner3));
            items.Add(Constants.GetPoint(Bot.Location.ButtonRightInner1));


            int cnt = 0;

            while (!CheckIfInFactory())
            {
                touch.ClickAt(Bot.Location.FirstFactory);
                BotApplication.Wait(200);
                cnt++;
                if (cnt > 10)
                {
                    break;
                }
            }
            //cnt = 0;
            //while (!CheckIfInFactory())
            //{
            //    touch.ClickAt(new Point(830, 538));
            //    BotApplication.Wait(200);
            //    cnt++;
            //    if (cnt > 10) break;

            //}

            if (!CheckIfInFactory())
            {
                ProcedureItems();
                return;
            }
            //touch.Swipe(Constants.GetPoint(Bot.Location.FactoryResource1), Constants.GetPoint(Bot.Location.CentreMap));
            //424 678
            for (int j = 0; j < 6; j++) // 5 factories
            {
                //CollectFactoryItem(5);
                int[] AllStatus = touch.CheckFactoryAllSlotStatus();

                log.Info("Status of all 5 slots :" + string.Join(",", AllStatus));
                int emptyCount = 0;

                for (int i = 0; i < AllStatus.Length; i++)
                {
                    int x = 358 + 142 * i;
                    int y = 675;
                    if (AllStatus[i] == 1)
                    {
                        touch.ClickAt(new Point(x, y));
                        BotApplication.Wait(20);
                        emptyCount++;
                    }
                    if (AllStatus[i] == 0)
                    {
                        emptyCount++;
                    }
                }

                /*
                 *
                 * for (int i = 0; i < AllStatus.Length; i++)
                 * {
                 *  int x = 429 + 142 * i;
                 *  int y = 675;
                 *  if (AllStatus[i] == 1)
                 *  {
                 *      touch.ClickAt(new Point(x, y));
                 *      BotApplication.Wait(20);
                 *      emptyCount++;
                 *  }
                 *  if (AllStatus[i] == 0)
                 *  {
                 *      emptyCount++;
                 *  }
                 * }
                 */
                for (int i = 0; i < emptyCount; i++)
                {
                    Point pr = items[rnd.Next(items.Count)];
                    touch.Swipe(pr, Constants.GetPoint(Bot.Location.CentreMap)); // procedure

                    BotApplication.Wait(30);
                }
                Bot.BotApplication.Wait(100);
                nextFactory();
                Bot.BotApplication.Wait(100);
            }
            if (CheckIfInFactory())
            {
                touch.sendRawEvent("1 1 1");
                touch.sendRawEvent("0 0 0");
                // touch.ClickAt(new Point(655, 77));

                /*
                 * /dev/input/event7: 0001 0001 00000001
                 * /dev/input/event7: 0000 0000 00000000
                 */
            }
        }
Exemplo n.º 13
0
        public bool CreateSellItem(int n, int at)
        {
            int row = 0;
            int col = 0;

            row = (int)Math.Floor((double)at / 4);
            row = row % 2;
            col = at % 4;

            if (n == 1)
            {
                touch.ClickAt(new Point(428 + 146 * col, 260 + 182 * row)); // click bua` hi vong se trung o
                Bot.BotApplication.Wait(100);
                if (touch.CheckPixel(1033, 131, Color.White, 10))           // if create sell form are show
                {
                    log.Info("Sell form are showed start selling at  [" + col + "," + row + "] ");
                    touch.ClickAt(new Point(325, 297));
                    Bot.BotApplication.Wait(100);
                    SetPriceAndQty();
                    Bot.BotApplication.Wait(200);
                }
                else
                {
                    // 808 116
                    if (touch.CheckPixel(808, 116, Color.White, 10)) //if edit sell form are show
                    {
                        touch.ClickAt(new Point(808, 116));
                        Bot.BotApplication.Wait(100);
                    }
                    else   // if nothing happend then phat click bua thanh ra collect cmnr
                    {
                        touch.ClickAt(new Point(428 + 146 * col, 260 + 182 * row));
                        Bot.BotApplication.Wait(100);
                        if (touch.CheckPixel(1033, 131, Color.White, 10)) // if create sell form are show
                        {
                            log.Info("Sell form are showed start selling at  [" + col + "," + row + "] ");
                            touch.ClickAt(new Point(325, 297));
                            Bot.BotApplication.Wait(100);
                            SetPriceAndQty();
                            Bot.BotApplication.Wait(200);
                        }
                        else
                        {
                            touch.ClickAt(new Point(873, 183));
                            Bot.BotApplication.Wait(100);

                            return(false);
                        }
                    }
                }



                return(true);
            }



            int x = 409 + 146 * col;
            int y = 305 + 182 * row;

            Color  c     = touch.GetPixel(409 + 146 * col, 305 + 182 * row);
            double delta = compareColor(c, Color.FromArgb(255, 119, 173, 45));

            if (delta < 10) // if sold then collect gold
            {
                log.Info(" Slot [" + col + "," + row + "] are sold");

                touch.ClickAt(new Point(409 + 146 * col, 305 + 182 * row)); //collect
                Bot.BotApplication.Wait(100);

                // then create sell
                touch.ClickAt(new Point(409 + 146 * col, 305 + 182 * row));
                Bot.BotApplication.Wait(100);
                touch.ClickAt(new Point(325, 297));
                Bot.BotApplication.Wait(100);
                SetPriceAndQty();
                Bot.BotApplication.Wait(200);
            }
            else
            {
                c     = touch.GetPixel(428 + 146 * col, 260 + 182 * row);
                delta = compareColor(c, Color.FromArgb(255, 255, 255, 255));

                if (delta < 10)
                {
                    log.Info("Slot [" + col + "," + row + "] selling");


                    // click for edit sell
                    touch.ClickAt(new Point(428 + 146 * col, 260 + 182 * row));

                    // 723 492
                    //rgb 40 , 122 , 161
                    BotApplication.Wait(50);
                    c     = touch.GetPixel(723, 492);
                    delta = compareColor(c, Color.FromArgb(255, 40, 122, 161));
                    log.Info("adv status " + delta);
                    if (delta < 50)      // check if can advsertise
                    {
                        touch.ClickAt(new Point(723, 492));
                    }
                    // then close
                    BotApplication.Wait(50);
                    touch.ClickAt(new Point(802, 124));
                    BotApplication.Wait(20);
                }
                else
                {
                    log.Info("Slot [" + col + "," + row + "] avaiable");



                    // then create sell
                    touch.ClickAt(new Point(409 + 146 * col, 305 + 182 * row));
                    Bot.BotApplication.Wait(200);
                    touch.ClickAt(new Point(325, 297));
                    Bot.BotApplication.Wait(200);
                    SetPriceAndQty();
                    Bot.BotApplication.Wait(200);
                }
            }

            /*if ((at + 1) % 8 == 0)
             * {
             *  //touch.Execute("input touchscreen swipe 923 300 339 300");
             *  touch.Execute("input touchscreen swipe 923 300 384 300");
             *
             *  Bot.BotApplication.Wait(150);
             * }*/
            return(true);
        }
Exemplo n.º 14
0
 public WebhookEndpointFunction(BotApplication botApplication)
 {
     BotApplication = botApplication;
 }