Exemplo n.º 1
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            //инициализируем класс
            NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);
            //Пытаемся залогиниться через проксики
            if (Bot.Login() == NerZul.Core.Utils.ManagedCitizen.LoginResult.Success)
            //Bot.Bot.Login();	//if(true)
            {
                ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
                botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                try
                {
                    if (((int)botinfo["activated"]) == 0)
                    {
                        Bot.Bot.Activate();
                        botinfo["activated"] = 1;
                        Utils.UpdateDbWithCustomBotInfo(botinfo, "activated");
                        botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    }
                }
                catch (System.Exception e)
                {
                    ConsoleLog.WriteLine("Error: " + e.Message);
                }

                Bot.Bot.VoteArticle(id);
            }
            else
            {
                ConsoleLog.WriteLine("Unable to login - " + botinfo["login"]);
            }
            #else
            ConsoleLog.WriteLine("Думаешь самый умный? Сказано, не работает!");
            #endif
        }
Exemplo n.º 2
0
 static void BotProc2(object botnfo)
 {
     var botinfo = (DbRow)botnfo;
     //инициализируем класс
     NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
         (string)botinfo["login"],
         (string)botinfo["email"],
         (string)botinfo["password"],
         Globals.BotConfig);
     //Пытаемся залогиниться через проксики
     if (Bot.Login() == NerZul.Core.Utils.ManagedCitizen.LoginResult.Success)
     //Bot.Bot.Login();	//if(true)
     {
         ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
         botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
         try
         {
             Bot.Bot.Comment(iId, sMess);
         }
         catch (System.Exception e)
         {
             ConsoleLog.WriteLine("Error: " + e.Message);
         }
     }
     else
     {
         if (Bot.Bot.GetLastResponse().Contains("infringement"))
         {
             botinfo["banned"] = 1;
             Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
             //botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
             ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Banned");
         }
         else
             ConsoleLog.WriteLine("Unable to login - " + botinfo["login"]);
     }
     #else
     ConsoleLog.WriteLine("Думаешь самый умный? Сказано, не работает!");
     #endif
 }
Exemplo n.º 3
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            //инициализируем класс
            NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);
            //Пытаемся залогиниться через проксики
            if (Bot.Login() == NerZul.Core.Utils.ManagedCitizen.LoginResult.Success)
            //Bot.Bot.Login();	//if(true)
            {
                ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
                botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                //++что-то делаем

            }
            else
            {
                ConsoleLog.WriteLine("Unable to login - " + botinfo["login"]);
            }
        }
Exemplo n.º 4
0
        static void BotProc(DbRow botinfo)
        {
            Random rnd = new Random();
            NerZul.Core.Utils.ManagedCitizen bot=new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);

            if(bot.Login()!=NerZul.Core.Utils.ManagedCitizen.LoginResult.Success)
            //if(!bot.Bot.Login())
            {
                ConsoleLog.WriteLine("Unable to login - "+ (string)botinfo["login"]);
            }
            if (bot.Bot.GetLastResponse().Contains("dead"))
            {
                ConsoleLog.WriteLine("Possible dead!");

            }

            ConsoleLog.WriteLine("Logged in - "+botinfo["login"]);
            //Join party if needed
            //            bool bChangedParty = false;
            if((string)botinfo["party"]!=party)
            {
                try
                {
                    if ((string)botinfo["party"] != "")
                    {
                        bot.Bot.LeaveParty((string)botinfo["party"]);
                    }

                }
                catch (System.Exception e)
                {
                    ConsoleLog.WriteLine("LeaveParty error: " + e.ToString());
                }
                if ((operation == "join" || operation == "vote") && (string)botinfo["party"] != party)
                {
                    try
                    {
                        if (!bot.Bot.JoinParty(party))
                        {
                            ConsoleLog.WriteLine("Unable to join party - " + (string)botinfo["login"]);
                            return;
                        }
                    }
                    catch (System.Exception e)
                    {
                        ConsoleLog.WriteLine("JoinParty error: " + e.ToString());
                    }

                    botinfo["party"] = party;
            //                    bChangedParty = true;
                }
                else
                    botinfo["party"] = "";
                Utils.UpdateDbWithCustomBotInfo(botinfo,"party");
            }
            if (operation == "vote")
            {

                    switch(electiontype)
                    {
                        case "vote-for-congress":
                            try
                            {
                                if (!bot.Bot.VoteCongress(electionid, candidate))
                                {
                                    ConsoleLog.WriteLine("Unable to vote- " + botinfo["login"]);
                                    return;
                                }
                                botinfo["last_day_vote"] = Globals.GetErepTime().Days;
                                Utils.UpdateDbWithCustomBotInfo(botinfo, "last_day_vote");

                            }
                            catch (System.Exception e)
                            {
                                ConsoleLog.WriteLine("VoteCongress error: " + e.ToString());
                            }
                            break;
                        case "vote-party-election":
                            try
                            {
                                if (!bot.Bot.VoteParty(electionid, candidate))
                                {
                                    ConsoleLog.WriteLine("Unable to vote- " + botinfo["login"]);
                                    return;
                                }
                                botinfo["last_day_vote"] = Globals.GetErepTime().Days;
                                Utils.UpdateDbWithCustomBotInfo(botinfo, "last_day_vote");

                            }
                            catch (System.Exception e)
                            {
                                ConsoleLog.WriteLine("VoteParty error: " + e.ToString());
                            }
                            break;
                        default:
                            break;
                    }

            //                 botinfo["last_day_vote"] = Globals.GetErepTime().Days;
            //                 Utils.UpdateDbWithCustomBotInfo(botinfo, "last_day_vote");
            //                 if (bChangedParty)
            //                 {
            //                     try
            //                     {
            //                         if (!bot.Bot.LeaveParty(party))
            //                         {
            //                             ConsoleLog.WriteLine("Unable to leave party - " + botinfo["login"]);
            //                             return;
            //                         }
            //                     }
            //                     catch (System.Exception e)
            //                     {
            //                         ConsoleLog.WriteLine("LeaveParty error: " + e.ToString());
            //                     }
            //
            //                     botinfo["party"] = "";
            //                     Utils.UpdateDbWithCustomBotInfo(botinfo, "party");
            //                 }
            }
            //System.Threading.Thread.Sleep(20000);
            #else
            ConsoleLog.WriteLine("Думаешь самый умный? Сказано, не работает!");
            #endif
        }
Exemplo n.º 5
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            Random rnd = new System.Random();

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            //инициализируем класс
            NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);
            //Пытаемся залогиниться через проксики

            ManagedCitizen.LoginResult loginResult;

            loginResult = Bot.Login();

            if (loginResult == ManagedCitizen.LoginResult.Success)
            {
                ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
                try
                {
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    Bot.Bot.ReportTicket(iId, iType, lang, stype);
                }
                catch (System.Exception e2)
                {
                    ConsoleLog.WriteLine("ReportAll error - " + botinfo["login"] + e2.ToString());
                }
            }
        }
Exemplo n.º 6
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            //инициализируем класс
            NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);

            ManagedCitizen.LoginResult loginResult;
            loginResult = Bot.Login();

            if (loginResult == ManagedCitizen.LoginResult.Success)
            {
                ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
                botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                // Смотрим состояние инвентаря
                if (Bot.GetStorageInfo(true))
                {
                    botinfo = Utils.TryToUpdateDbWithStorageInfo(botinfo, Bot);
                }

                if ((iLeftFood == 0) ||
                    (Bot.storageInfo.foodQty >= iLeftFood))
                {
                    for (int i = 1; i <= 3; i++)
                    {
                        if (cyclicFight)
                            ConsoleLog.WriteLine("Cyclic fight, try " + i.ToString());

                        int iter = 0;
                        int retryCount = 0;
                        float wellness = (float)botinfo["wellness"];
                        float oldWellness = 0;

                        do
                        {
                            System.Threading.Thread.Sleep(1500);
                            iter++;

                            if (iter > 10) break;

                            if (wellness > iLeftHP)
                            {
                                if (cyclicFight)
                                    ConsoleLog.WriteLine("Cyclic fight, iteration " + iter.ToString() + ". Fight!");

                                Bot.Bot.FightInBattle(iBattle, ((bBuyWeapon) ? 1 : 0), (int)botinfo["country"], iLeftHP, iCountry, doNotChange, iShotLimit);
                            }

                            Bot.GetInfoFromCommonResponse(true);
                            botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                            if (cyclicFight)
                            {
                                ConsoleLog.WriteLine("Cyclic fight, iteration " + iter.ToString() + ". Feed!");
                                Bot.Feed(!Globals.BotConfig.useTOR, (int)botinfo["country"], Globals.defaultFoodQ, 97, !bBuyFood, true);
                            }

                            Bot.GetInfoFromCommonResponse(true);
                            botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                            wellness = (float)botinfo["wellness"];

                            ConsoleLog.WriteLine("Fight finished. Wellness left: " + wellness.ToString());

                            if (oldWellness == wellness)
                            {
                                retryCount++;
                            }
                            else
                            {
                                oldWellness = wellness;
                                retryCount = 0;
                            }

                            if ((!cyclicFight) ||
                                (retryCount >= 3) ||
                                ((iExpLimit != 0) && ((int)botinfo["experience"]) >= iExpLimit))
                                break;
                        }
                        while (wellness > iLeftHP);

                        if ((!cyclicFight) ||
                           ((iExpLimit != 0) && ((int)botinfo["experience"]) >= iExpLimit))
                            break;
                    }
                }

                // Смотрим состояние инвентаря
                if (Bot.GetStorageInfo(true))
                {
                    botinfo = Utils.TryToUpdateDbWithStorageInfo(botinfo, Bot);
                }
            }
            else
                if ((loginResult == ManagedCitizen.LoginResult.Banned) ||
                    (loginResult == ManagedCitizen.LoginResult.Banned2))
                {
                    botinfo["banned"] = (loginResult == ManagedCitizen.LoginResult.Banned) ? 1 : 2;
                    Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                    //botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                }
                //else
                //    if (Bot.Bot.GetLastResponse().Contains("infringement"))
                //    {
                //        botinfo["banned"] = 1;
                //        Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                //        //botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                //        ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Banned");
                //    }
                else
                {
                    //ConsoleLog.WriteLine(Bot.Bot.GetLastResponse(), "LoginLog.txt");
                    ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Possibly dead, see LoginLog.txt");
                }
        }
Exemplo n.º 7
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            try
            {
                //инициализируем класс
                ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                    (string)botinfo["login"],
                (string)botinfo["email"],
                    (string)botinfo["password"],
                    Globals.BotConfig);
                //Пытаемся залогиниться через проксики

                ManagedCitizen.LoginResult loginResult;

                loginResult = Bot.Login();

                if (loginResult == ManagedCitizen.LoginResult.Success)
                {
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    ConsoleLog.WriteLine("Logged in - " + Bot.Bot.LoginName);

                    Bot.Feed(!Globals.BotConfig.useTOR, (int)botinfo["country"], food_quality, for_health, justEat, fastFood);

                    Utils.TryToUpdateDbWithCurrentInfo(botinfo, Bot);
                }
                else
                    if ((loginResult == ManagedCitizen.LoginResult.Banned) ||
                        (loginResult == ManagedCitizen.LoginResult.Banned2))
                    {
                        botinfo["banned"] = (loginResult == ManagedCitizen.LoginResult.Banned) ? 1 : 2;
                        Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                        //botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    }
                    //else
                    //    if (Bot.Bot.GetLastResponse().Contains("infringement"))
                    //    {
                    //        botinfo["banned"] = 1;
                    //        Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                    //        //botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    //        ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Banned");
                    //    }
                    else
                    {
                        //ConsoleLog.WriteLine(Bot.Bot.GetLastResponse(), "LoginLog.txt");
                        ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Possibly dead, see LoginLog.txt");
                    }
            }
            catch (System.Exception e)
            {
                ConsoleLog.WriteLine("Feed exception: " + e.Message);
            }
        }
Exemplo n.º 8
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            Random rnd = new System.Random();

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            //инициализируем класс
            NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);
            //Пытаемся залогиниться через проксики

            ManagedCitizen.LoginResult loginResult = Bot.Login();
            if (loginResult == ManagedCitizen.LoginResult.Success)
            {
                try
                {
                    Bot.Bot.m_Client.Timeouts = 0;

                    ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                    #region Активируем, если в базе нет отметки что активен. Посещаем диснейленд в первый раз
                    try
                    {
                        if (((int)botinfo["activated"]) == 0)
                        {
                            if (!Globals.BotConfig.useTOR) System.Threading.Thread.Sleep(rnd.Next(2000, 5000));
                            Bot.Bot.Activate();
                            botinfo["activated"] = 1;
                            Utils.UpdateDbWithCustomBotInfo(botinfo, "activated");
                            botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                            ConsoleLog.WriteLine("Visit 'Land' for the first time");
                            Bot.Bot.VisitLand((uint)botinfo["citizen_id"]);

                        }
                    }
                    catch (System.Exception e)
                    {
                        ConsoleLog.WriteLine("Error activation: " + e.Message);
                    }

                    if (Bot.Bot.m_Client.Timeouts >= Globals.timeoutsLimit)
                        throw new Exception("Timeout limit reached.");
                    #endregion

                    // Смотрим состояние инвентаря
                    if (Bot.GetStorageInfo(true))
                    {
                        botinfo = Utils.TryToUpdateDbWithStorageInfo(botinfo, Bot);
                    }

                    #region Light mode. Light так light. НИЧЕГО не делаем, только собираем инфу и выходим
                    if (mode == "light")
                    {
                        if (!Globals.BotConfig.useTOR) System.Threading.Thread.Sleep(rnd.Next(1000, 2000));
                        Daily.BotLight(botinfo, Bot, rnd);
                        return;
                    }
                    #endregion

                    #region Покупаем и едим еду 1
                    if (doFeed == 1)
                        Bot.Feed(!Globals.BotConfig.useTOR, (int)botinfo["country"], Globals.defaultFoodQ, 99, true, true);

                    if (Bot.Bot.m_Client.Timeouts >= Globals.timeoutsLimit)
                        throw new Exception("Timeout limit reached.");
                    #endregion

                    #region Работаем, тренькаемся, читаем алерты, читаем статьи, смотрим TreasureMap
                    //, учимся, отдыхаем
                    List<int> lst = new List<int>();
                    lst.Add(1);
                    lst.Add(2);
                    lst.Add(3);
                    lst.Add(4);
                    lst = CommonUtils.MixList(lst);
                    for (List<int>.Enumerator e = lst.GetEnumerator(); e.MoveNext(); )
                    {
                        if (!Globals.BotConfig.useTOR) System.Threading.Thread.Sleep(rnd.Next(1000, 2000));
                        switch (e.Current)
                        {
                            case 1: // Работа
                                for (int i = 1; i <= 3; i++)
                                {
                                    try
                                    {
                                        Daily.BotWork(botinfo, Bot, rnd);
                                        break;
                                    }
                                    catch (System.Exception e1)
                                    {
                                        ConsoleLog.WriteLine("Bot work error: " + e1.Message);
                                    }
                                }
                                break;
                            case 2: // Тренька
                                for (int i = 1; i <= 3; i++)
                                {
                                    try
                                    {
                                        Daily.BotTrain(botinfo, Bot, rnd);
                                        break;
                                    }
                                    catch (System.Exception e1)
                                    {
                                        ConsoleLog.WriteLine("Bot train error: " + e1.Message);
                                    }
                                }
                                break;
                            case 3: // Аллерты
                                try
                                {
                                    Bot.Bot.LookAlerts();
                                }
                                catch (System.Exception e1)
                                {
                                    ConsoleLog.WriteLine("Bot look alerts error: " + e1.Message);
                                }
                                break;
                            case 4: // Статьи
                                try
                                {
                                    Bot.Bot.ReadRandomTopArticle();
                                    //if (!Globals.BotConfig.useTOR) System.Threading.Thread.Sleep(rnd.Next(15000, 20000));
                                    Bot.Bot.ReadRandomTopArticle();
                                }
                                catch (System.Exception e1)
                                {
                                    ConsoleLog.WriteLine("Bot read article error: " + e1.Message);
                                }
                                break;
                        }

                        if (Bot.Bot.m_Client.Timeouts >= Globals.timeoutsLimit)
                            throw new Exception("Timeout limit reached.");
                    }
                    #endregion

                    #region Получаем дневной reward
                    if (!Globals.BotConfig.useTOR) System.Threading.Thread.Sleep(rnd.Next(1000, 2000));
                    for (int i = 1; i <= 3; i++)
                    {
                        try
                        {
                            Bot.Bot.DailyReward();
                            break;
                        }
                        catch (System.Exception e)
                        {
                            ConsoleLog.WriteLine("Bot get daily reward error: " + e.Message);
                        }

                        if (Bot.Bot.m_Client.Timeouts >= Globals.timeoutsLimit)
                            throw new Exception("Timeout limit reached.");
                    }
                    #endregion

                    #region Покупаем и едим еду 2
                    if (doFeed == 2)
                        Bot.Feed(!Globals.BotConfig.useTOR, (int)botinfo["country"], Globals.defaultFoodQ, 99, true, true);

                    if (Bot.Bot.m_Client.Timeouts >= Globals.timeoutsLimit)
                        throw new Exception("Timeout limit reached.");
                    #endregion

                    // Смотрим состояние инвентаря
                    if (Bot.GetStorageInfo(true))
                    {
                        botinfo = Utils.TryToUpdateDbWithStorageInfo(botinfo, Bot);
                    }

                    #region Грузим аватару, если не загружена
                    try
                    {
                        //АВАТАРКА
                        if (/*((int)botinfo["experience"] >= 61) && */(!Bot.Info.HasAvatar))
                        //if (false)
                        {
                            ConsoleLog.WriteLine(botinfo["login"] + ": Upload avatar");
                            if (!Globals.BotConfig.useTOR) System.Threading.Thread.Sleep(rnd.Next(1000, 2000));
                            string Path = System.IO.Path.Combine(Globals.DataDir, "avatars");
                            Path = System.IO.Path.Combine(Path, Globals.Avatars.GetRandomString());
                            Bot.Bot.UploadAvatar(System.IO.File.ReadAllBytes(Path), Path);
                            botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                        }
                    }
                    catch (System.Exception e)
                    {
                        ConsoleLog.WriteLine("Error uploading avatar: " + e.Message);
                    }
                    #endregion
                }
                finally
                {
                    // Апдейтим статус бота в базе
                    botinfo = Utils.TryToUpdateDbWithCurrentInfo(botinfo, Bot);
                }

                // Logout
                Bot.Bot.Logout();
            }
            else
                if ((loginResult == ManagedCitizen.LoginResult.Banned) ||
                    (loginResult == ManagedCitizen.LoginResult.Banned2))
                {
                    botinfo["banned"] = (loginResult == ManagedCitizen.LoginResult.Banned)?1:2;
                    Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                }
                else
                {
                    //ConsoleLog.WriteLine(Bot.Bot.GetLastResponse(), "LoginLog.txt");
                    ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Possibly dead, see LoginLog.txt");
                }
            ConsoleLog.WriteLine(botinfo["login"].ToString() + ": daily proc finished");
        }
Exemplo n.º 9
0
        private static void BotProcConvertMoney(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            double lHowMuch = dHowMuch;

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            try
            {
                NerZul.Core.Utils.ManagedCitizen Bot = new ManagedCitizen(
                    (string)botinfo["login"],
                    (string)botinfo["email"],
                    (string)botinfo["password"],
                    Globals.BotConfig);

                ManagedCitizen.LoginResult loginResult = Bot.Login();
                if (loginResult == ManagedCitizen.LoginResult.Success)
                {
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);

                    int curRemains = 1;
                    for (int i = 1; i <= 20; i++)
                    {
                        try
                        {
                            ConsoleLog.WriteLine("Convert money, try " + i.ToString());

                            string response;
                            string URL;

                            int tmpRemains = GetCurrencyAmount(Bot, iCurrencySpendID, iCurrencyBuyID);

                            if (tmpRemains == -1)
                                continue;

                            curRemains = tmpRemains;

                            if (curRemains < 0.1)
                            {
                                ConsoleLog.WriteLine("Everything converted");
                                break;
                            }

                            // Открываем страницу ставок ММ, получаем первую нормальную ставку и ее параметры
                            ConsoleLog.WriteLine("Loading rates MM page...");
                            URL =
                                "http://www.erepublik.com/en/exchange/listOffers?select_page=select&buy_currency_history_id=buy_currencies=" +
                                iCurrencyBuyID.ToString() +
                                "&sell_currency_history_id=sell_currencies=" +
                                iCurrencySpendID.ToString() +
                                "&account_type=citizen-&action_path=listOffers&page=page=1";
                            //ConsoleLog.WriteLine("URL: " + URL);
                            response = Bot.Bot.CustomRequest(URL);

                            //ConsoleLog.WriteLine(response, "ConvertMoneyLog2.txt");

                            if (!response.Contains("form_amount_accept_"))
                            {
                                ConsoleLog.WriteLine("Error rates MM page");
                                continue;
                            }

                            int iOfferID = 0;
                            double dPosRate = 0;
                            double dPosAmount = 0;
                            int iCorrespondentID = 0;

                            for (int rateNum = 1; rateNum <= 10; rateNum++)
                            {

                                string sOfferId = CommonUtils.GetStringBetween(
                                    response,
                                    "\"form_amount_accept_",
                                    "\"");
                                string sPosRate = CommonUtils.GetStringBetween(
                                    response,
                                    "<span class=\"special\" id=\"exchange_value_amount_" + sOfferId + "\">",
                                    "</span>");
                                string sPosAmount = CommonUtils.GetStringBetween(
                                    response,
                                    "<span class=\"special\"  id=\"initial_amount_" + sOfferId + "\">",
                                    "</span>");
                                string sCorrespondentID = CommonUtils.GetStringBetween(
                                    response,
                                    "<a class=\"nameholder dotted\" href=\"/en/citizen/profile/",
                                    "\">");

                                ConsoleLog.WriteLine("Detected position " + rateNum.ToString() + ": OfferId=" + sOfferId + ", PosRate=" + sPosRate + ", PosAmount=" + sPosAmount + ", CorrespondentID=" + sCorrespondentID);

                                iOfferID = Convert.ToInt32(sOfferId);
                                dPosRate = Convert.ToDouble(sPosRate);
                                dPosAmount = Convert.ToDouble(sPosAmount);
                                iCorrespondentID = Convert.ToInt32(sCorrespondentID);

                                if (dPosAmount < 0.01)
                                {
                                    ConsoleLog.WriteLine("Position amount less then 0.01, getting next position");
                                    response = response.Substring(response.IndexOf("submit_form_accept") + 10);
                                }
                                else
                                    break;
                            }

                            if (dPosRate > fMaxRate)
                            {
                                ConsoleLog.WriteLine("Rate greater then max possible, waiting 10 sec...");
                                System.Threading.Thread.Sleep(10000);
                                continue;
                            }

                            //double dToBuy = Math.Min(Math.Truncate(curRemains / dPosRate), dPosAmount);
                            double dToBuy = Math.Min(curRemains / dPosRate - 0.01, dPosAmount);
                            dToBuy = Math.Truncate(dToBuy * 100) / 100;

                            ConsoleLog.WriteLine("Buy " + dToBuy.ToString() + " currency");
                            if (Bot.Bot.BuyMoney(iOfferID, dToBuy, iCurrencySpendID, iCorrespondentID, iCurrencyBuyID))
                            {
                                ConsoleLog.WriteLine("Buy currency successfull");
                            }
                            else
                            {
                                ConsoleLog.WriteLine("Buy currency fail");
                            }
                        }
                        catch (System.Exception localE)
                        {
                            ConsoleLog.WriteLine("Local convert exception: " + localE.Message);
                        }
                    }

                    Bot.GetInfoFromCommonResponse(true);
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                    // Logout
                    Bot.Bot.Logout();
                }
                else
                    if ((loginResult == ManagedCitizen.LoginResult.Banned) ||
                        (loginResult == ManagedCitizen.LoginResult.Banned2))
                    {
                        botinfo["banned"] = (loginResult == ManagedCitizen.LoginResult.Banned) ? 1 : 2;
                        Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                    }
                    else
                    {
                        //ConsoleLog.WriteLine(Bot.Bot.GetLastResponse(), "LoginLog.txt");
                        ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Possibly dead, see LoginLog.txt");
                    }
            }
            catch (System.Exception e)
            {
                ConsoleLog.WriteLine("Convert exception: " + e.Message);
            }
        }
Exemplo n.º 10
0
        private static void BotProcCollectmoneyToCountry(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            Random rnd = new System.Random();

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            //инициализируем класс
            NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);
            //Пытаемся залогиниться через проксики

            ManagedCitizen.LoginResult loginResult = Bot.Login();
            if (loginResult == ManagedCitizen.LoginResult.Success)
            {
                ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
                botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                int curRemains = 1;
                for (int i = 1; i <= 20; i++)
                {
                    try
                    {
                        ConsoleLog.WriteLine("Collect money to country, try " + i.ToString());

                        int tmpRemains = GetCurrencyAmount(Bot, iCurrencySpendID, 0);

                        if (tmpRemains == -1)
                            continue;

                        curRemains = tmpRemains;

                        if (curRemains < 0.1)
                        {
                            ConsoleLog.WriteLine("Everything collected");
                            break;
                        }

                        if (Bot.Bot.DonateMoneyToCountry(sDestinationCountry, curRemains - 0.01, iCurrencySpendID))
                        {
                            ConsoleLog.WriteLine("Collect money to country successfull");
                        }
                        else
                        {
                            ConsoleLog.WriteLine("Collect money to country fail");
                        }

                    }
                    catch (System.Exception e1)
                    {
                        ConsoleLog.WriteLine("Collect money to country - error" + e1.ToString());
                    }

                    Bot.GetInfoFromCommonResponse(true);
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                    // Logout
                    Bot.Bot.Logout();
                }
            }
            else
                if ((loginResult == ManagedCitizen.LoginResult.Banned) ||
                    (loginResult == ManagedCitizen.LoginResult.Banned2))
                {
                    botinfo["banned"] = (loginResult == ManagedCitizen.LoginResult.Banned) ? 1 : 2;
                    Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                }
                else
                {
                    //ConsoleLog.WriteLine(Bot.Bot.GetLastResponse(), "LoginLog.txt");
                    ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Possibly dead, see LoginLog.txt");
                }
        }
Exemplo n.º 11
0
        private static void BotProcBuyFromOffer(object botnfo)
        {
            var botinfo = (DbRow)botnfo;

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            try
            {
                NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                    (string)botinfo["login"],
                    (string)botinfo["email"],
                    (string)botinfo["password"],
                    Globals.BotConfig);

                ManagedCitizen.LoginResult loginResult = Bot.Login();
                if (loginResult == ManagedCitizen.LoginResult.Success)
                {
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);

                    if (iCorrespondentID == Convert.ToInt32((uint)botinfo["citizen_id"]))
                    {
                        ConsoleLog.WriteLine("Cannot buy from the same account, exiting");
                        return;
                    }

                    for (int i = 1; i <= 10; i++)
                    {
                        try
                        {
                            double lHowMuch = dHowMuch;

                            ConsoleLog.WriteLine("BuyFromOffer money, try " + i.ToString());

                            if (lHowMuch == 0)
                            {
                                int tmpRemains = GetCurrencyAmount(Bot, iCurrencySpendID, iCurrencyBuyID);

                                if (tmpRemains == -1)
                                    continue;

                                lHowMuch = tmpRemains * 0.001 - 0.01;
                            }
                            if (lHowMuch < 0.02)
                            {
                                ConsoleLog.WriteLine("Nothing to drain");
                                break;
                            }

                            lHowMuch = Math.Truncate(lHowMuch * 100) / 100;

                            ConsoleLog.WriteLine("Buy " + lHowMuch.ToString() + " currency");

                            if (Bot.Bot.BuyMoney(iOffer, lHowMuch, iCurrencySpendID, iCorrespondentID, iCurrencyBuyID))
                            {
                                //ConsoleLog.WriteLine(botinfo["login"] + ": Gold drained. Waiting for 1 minute.");
                                ConsoleLog.WriteLine(botinfo["login"] + ": Gold drained.");
                            }
                            else
                            {
            //                                ConsoleLog.WriteLine(botinfo["login"] + ": Gold drain failed. Waiting for 1 minute.");
                                ConsoleLog.WriteLine(botinfo["login"] + ": Gold drain failed.");
                            }

                            // Если сливаем нац. валюту -- обновляем инфу
                            if (iCurrencySpendID == (int)botinfo["country"])
                                Bot.GetInfoFromCommonResponse(true);

                            //System.Threading.Thread.Sleep(60000);

                            if (dHowMuch != 0)
                                break;
                        }
                        catch (System.Exception localE)
                        {
                            ConsoleLog.WriteLine("Local convert exception: " + localE.Message);
                        }
                    }

                    // Logout
                    Bot.Bot.Logout();

                }
                else
                    if ((loginResult == ManagedCitizen.LoginResult.Banned) ||
                        (loginResult == ManagedCitizen.LoginResult.Banned2))
                    {
                        botinfo["banned"] = (loginResult == ManagedCitizen.LoginResult.Banned) ? 1 : 2;
                        Utils.UpdateDbWithCustomBotInfo(botinfo, "banned");
                    }
                    else
                    {
                        //ConsoleLog.WriteLine(Bot.Bot.GetLastResponse(), "LoginLog.txt");
                        ConsoleLog.WriteLine(botinfo["login"].ToString() + ": Possibly dead, see LoginLog.txt");
                    }
            }
            catch (System.Exception e)
            {
                ConsoleLog.WriteLine("BuyFromOffer exception: " + e.Message);
            }
        }
Exemplo n.º 12
0
        public static void WorkerDonateMoney(string[] args)
        {
            //#if PUBLIC_BUILD
            if (!Globals.IsValid())
                return;
            //#endif

            if (args.Length != 6)
            {
                ConsoleLog.WriteLine("Usage: donatemoney group login(email) password currency amount");
                return;
            }

            group = args[1];
            login = args[2];
            password = args[3];
            int.TryParse(args[4], out iCurrencySpendID);
            double.TryParse(args[5], out dHowMuch);

            try
            {
                //инициализируем класс
                NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                    login,
                    login,
                    password,
                    Globals.BotConfig);
                //Пытаемся залогиниться через проксики

                ManagedCitizen.LoginResult loginResult = Bot.Login();
                if (loginResult == ManagedCitizen.LoginResult.Success)
                {
                    ConsoleLog.WriteLine("Logged in - " + login);

                    DbRows bots = null;
                    lock (Globals.DBLocker)
                    {
                        Globals.Database.Reset();
                        if (group.ToLower() != "all")
                            Globals.Database.Where("group", group);
                        Globals.Database.Where("banned", 0);
                        if (!String.IsNullOrEmpty(Globals.addWhere))
                            Globals.Database.Where(Globals.addWhere);
                        bots = Globals.Database.Select("bots");
                        Globals.Database.Reset();
                    }
                    if (!Globals.webCitadel.SendLogInfo(args, bots.Count))
                        return;

                    int totalBotCounter = bots.Count;
                    int processedBotCounter = 0;
                    bots = DbRows.MixList(bots);
                    DbRow botinfo;
                    Random rnd = new System.Random();

                    foreach (var botnfo in bots)
                    {
                        botinfo = (DbRow)botnfo;

                        processedBotCounter++;
                        ConsoleLog.WriteLine(
                            "Processing bot " +
                            processedBotCounter.ToString() + "/" +
                            totalBotCounter.ToString() + ": " +
                            (string)botinfo["login"]);

                        try
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                ConsoleLog.WriteLine("Donate money to " + botinfo["login"] + ", try " + (i + 1).ToString());
                                if (Bot.Bot.DonateMoney(Convert.ToInt32((uint)botinfo["citizen_id"]), dHowMuch, iCurrencySpendID))
                                    break;
                            }
                            Bot.GetInfoFromCommonResponse(true);
                        }
                        catch (System.Exception e1)
                        {
                            ConsoleLog.WriteLine("Donate - error" + e1.ToString());
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                ConsoleLog.WriteLine("Worker error: " + e.Message);
            }

            ConsoleLog.WriteLine("Donate done!");
        }
Exemplo n.º 13
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            Random rnd = new System.Random();

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            try
            {
                //инициализируем класс
                ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                    (string)botinfo["login"],
                    (string)botinfo["email"],
                    (string)botinfo["password"],
                    Globals.BotConfig);
                //Пытаемся залогиниться через проксики
                if (Bot.Login() == ManagedCitizen.LoginResult.Success)
                //Bot.Bot.Login();	//if(true)
                {
                    botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);
                    ConsoleLog.WriteLine("Logged in - " + Bot.Bot.LoginName);

                    if (buyFood)
                    {
                        ConsoleLog.WriteLine("Покупает 3 булки");
                        Bot.Bot.BuyItem(int.Parse(botinfo["country"].ToString()), Goods.Food, 3, 0, 0, true);
                    }

                    if (buyWeapons)
                    {
                        ConsoleLog.WriteLine("Покупает 3 пушки");
                        Bot.Bot.BuyItem(int.Parse(botinfo["country"].ToString()), Goods.Weapon, 3, 0, 0, true);
                    }

                    for (int i = 0; i < 5; i++)
                    {
                        string response = Bot.Bot.m_Client.DownloadString("http://www.erepublik.com/en");

                        Match m = Regex.Match(response, "var missionsJSON = (\\[.*?\\]);\\s*var csrfToken = '([^']+)';");
                        string MissionsJson = m.Groups[1].Value;
                        string MissionsToken = m.Groups[2].Value;

                        if (collectAll)
                        {
                            for (int q = 1; q < 16; i++)
                            {
                                Bot.Bot.DoMission(q, false, MissionsToken);
                            }
                            break;
                        }
                        else
                        {
                            if (Bot.Bot.DoMissionsFromJson(MissionsJson, MissionsToken) == 0)
                                break;
                        }
                    }

                    /*
                    for (int i = 0; i < 2; i++)
                    {
                        ConsoleLog.WriteLine(
                            Bot.Bot.LoginName + " - try to buy 3 " + ((i == 0) ? "food" : "guns"));

                        try
                        {
                            System.Threading.Thread.Sleep(rnd.Next(1000, 2000));
                            // Первые 3 раза покупаем булки, вторые 3 раза пушки
                            Bot.Bot.BuyItem(int.Parse(botinfo["country"].ToString()), (i==0)?Goods.Food:Goods.Weapon, 3, 0, 0, 0, 0);
                            Bot.GetInfoFromCommonResponse();
                            ConsoleLog.WriteLine(
                                Bot.Bot.LoginName + " - after buy. " +
                                "Currency left: " + Bot.Info.Nat_occur.ToString());
                        }
                        catch (Exception e)
                        {
                            ConsoleLog.WriteLine("Error buying: " + e.Message);
                        }
                    }
                    */

                    /*
                    //Utils.TryToUpdateDbWithCurrentInfo(botinfo, Bot);
                    //Вроде нечем апдейтить, к сожалению.

                    #region FEED
                    try
                    {
                        ConsoleLog.WriteLine(Bot.Bot.LoginName + " - collecting FEED quest");
                        Bot.Bot.RewardFeed();
                    }
                    catch (Exception e)
                    {
                        ConsoleLog.WriteLine("Error collecting FEED quest: " + e.Message);
                    }
                    #endregion

                    #region WEAPON
                    try
                    {
                        ConsoleLog.WriteLine(Bot.Bot.LoginName + " - collecting WEAPON quest");
                        Bot.Bot.RewardWeapoon();
                    }
                    catch (Exception e)
                    {
                        ConsoleLog.WriteLine("Error collecting WEAPON quest: " + e.Message);
                    }
                    #endregion

                    #region HERO
                    try
                    {
                        ConsoleLog.WriteLine(Bot.Bot.LoginName + " - collecting HERO quest");
                        Bot.Bot.RewardHero();
                    }
                    catch (Exception e)
                    {
                        ConsoleLog.WriteLine("Error collecting HERO quest: " + e.Message);
                    }
                    #endregion

                    #region WORKING ROW
                    try
                    {
                        ConsoleLog.WriteLine(Bot.Bot.LoginName + " - collecting WORKING ROW quest");
                        Bot.Bot.RewardWorkingRow();
                    }
                    catch (Exception e)
                    {
                        ConsoleLog.WriteLine("Error collecting WORKING ROW quest: " + e.Message);
                    }
                    #endregion

                    #region SOCIETY
                    try
                    {
                       ConsoleLog.WriteLine(Bot.Bot.LoginName + " - collecting SOCIETY quest");
                       Bot.Bot.RewardSociety();
                    }
                    catch (Exception e)
                    {
                       ConsoleLog.WriteLine("Error collecting SOCIETY quest: " + e.Message);
                    }
                    #endregion
                    */
                }
                else
                {
                    ConsoleLog.WriteLine("Unable to login - " + botinfo["login"]);
                }
            }
            catch (System.Exception e)
            {
                ConsoleLog.WriteLine("CollectQuests exception: " + e.Message);
            }
        }
Exemplo n.º 14
0
        static void BotProc(object botnfo)
        {
            var botinfo = (DbRow)botnfo;
            Random rnd = new System.Random();

            Globals.processedBotCounter++;
            ConsoleLog.WriteLine(
                "Processing bot " +
                Globals.processedBotCounter.ToString() + "/" +
                Globals.totalBotCounter.ToString() + ": " +
                (string)botinfo["login"]);

            //инициализируем класс
            NerZul.Core.Utils.ManagedCitizen Bot = new NerZul.Core.Utils.ManagedCitizen(
                (string)botinfo["login"],
                (string)botinfo["email"],
                (string)botinfo["password"],
                Globals.BotConfig);
            //Пытаемся залогиниться через проксики

            ManagedCitizen.LoginResult loginResult;

            loginResult = Bot.Login();

            if (loginResult == ManagedCitizen.LoginResult.Success)
            {
                ConsoleLog.WriteLine("Logged in - " + botinfo["login"]);
                botinfo = Utils.TryToUpdateDbWithBasicInfo(botinfo, Bot);

                try
                {
                    Bot.Bot.Resign();
                }
                catch (System.Exception e)
                {
                    ConsoleLog.WriteLine("Bot resign error: " + e.Message);
                }

                try
                {
                    System.Threading.Thread.Sleep(rnd.Next(1000, 2000));
                    Bot.Bot.BuyItem(int.Parse(botinfo["country"].ToString()), Goods.Ticket, 1, iDistance, 0, true);
                }
                catch (System.Exception e)
                {
                    ConsoleLog.WriteLine("Bot buy ticket error: " + e.Message);
                }

                try
                {
                    Bot.Bot.Fly(iCountry, iRegion);
                    botinfo = Utils.TryToUpdateDbWithCurrentInfo(botinfo, Bot);
                }
                catch (System.Exception e)
                {
                    ConsoleLog.WriteLine("Bot fly error: " + e.Message);
                }
            }
        }