public void AddRobber(string username, int vklad, string site)
        {
            string  file    = GlobalName.FilePathJson;
            Robbers players = GetListRobbers();

            Robber thisrobber = players.ListRobbers.Find(r => r.name == username.Trim().ToLower());

            if (thisrobber == null)
            {
                players.ListRobbers.Add(new Robber()
                {
                    name = username.Trim().ToLower(), amount = vklad
                });
                thisrobber = players.ListRobbers.Find(r => r.name == username.Trim().ToLower());
                RutonyBot.BotSay(site, username + ", спасибо за вклад. Ждем других участников!");

                try
                {
                    File.Delete(file);
                }
                catch { }

                string serialized = JsonConvert.SerializeObject(players);
                using (StreamWriter stream = File.CreateText(file))
                {
                    stream.Write(serialized);
                }
                //  RutonyBotFunctions.FileAddString(file, serialized);
            }
            else
            {
                RutonyBot.BotSay(site, username + ", вы уже вложились в ограбление.");
            }
        }
        public Robbers GetListRobbers()
        {
            string file = GlobalName.FilePathJson;

            Robbers players = new Robbers();

            if (File.Exists(file))
            {
                string[] filetexts = File.ReadAllLines(file);
                players = JsonConvert.DeserializeObject <Robbers>(filetexts[0]);
            }

            return(players);
        }
        public void RunScript(string site, string username, string text)
        {
            int         credit;
            RankControl db = new RankControl();

            RankControl.ChatterRank cr = db.ListChatters.Find(r => r.Nickname == username.Trim().ToLower());

            if (cr == null)
            {
                RutonyBot.BotSay(site,
                                 username + ", ошибка! Вашей записи нет в базе данных или она повреждена!");
                return;
            }

            if (!Int32.TryParse(text.Substring(text.IndexOf(" ") + 1), out credit))
            {
                RutonyBot.BotSay(site, "Количество кредитов должно быть больше 0!");
                return;
            }
            if (credit <= 0)
            {
                RutonyBot.BotSay(site, "Кредитов должно быть больше 0!");
                return;
            }
            if (cr.CreditsQty < credit)
            {
                RutonyBot.BotSay(site, string.Format("У вас всего {0} кредитов!", cr.CreditsQty));
                return;
            }
            cr.CreditsQty -= credit;

            if (!File.Exists(GlobalName.FilePathJson))
            {
                AddRobber(username, credit, site);
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;

                    Thread.Sleep(60000);

                    int sum = 0;

                    Robbers players = GetListRobbers();
                    foreach (Robber player in players.ListRobbers)
                    {
                        sum += player.amount;
                    }

                    Random winrnd = new Random();
                    int winrandom = winrnd.Next(1, 100);

                    int sumrandom = (sum / 10);
                    if (sumrandom > 25)
                    {
                        sumrandom = 25;
                    }

                    if (winrandom + sumrandom > 80)
                    {
                        string messageSuccess = "";
                        foreach (Robber player in players.ListRobbers)
                        {
                            player.amount = player.amount * 2;
                            RankControl.ChatterRank cr_win = db.ListChatters.Find(r => r.Nickname == player.name);
                            cr_win.CreditsQty += player.amount;
                            messageSuccess    += player.name + " получил " + player.amount + " кредитов! ";
                        }
                        RutonyBot.BotSay(site, "Ограбление прошло успешно! " + messageSuccess);
                    }
                    else
                    {
                        bool userBest = false;
                        foreach (Robber player in players.ListRobbers)
                        {
                            if (player.name == "alexkwest" || player.name == "alexkwest craft")
                            {
                                userBest = true;
                                RankControl.ChatterRank cr_win = db.ListChatters.Find(r => r.Nickname == player.name);
                                cr_win.CreditsQty += sum;
                                RutonyBot.BotSay(site, player.name + " заложил свою банду. Обнёс общаг суммой: " + sum + " и свалил. Его подельники остались с носом.");
                            }
                        }
                        if (!userBest)
                        {
                            Random randomBank = new Random();
                            int zeroCash      = randomBank.Next(1, 100);
                            if (zeroCash < 2)
                            {
                                string userBank = " ";
                                foreach (Robber player in players.ListRobbers)
                                {
                                    RankControl.ChatterRank cr_win = db.ListChatters.Find(r => r.Nickname == player.name);
                                    cr_win.CreditsQty = 0;
                                    userBank         += player.name + " ";
                                }
                                RutonyBot.BotSay(site, userBank + ", вас накрыл ОМОН и изъял все ваши грязные деньги.");
                            }
                            else
                            {
                                GetAnswer(site, "Примечание автора");
                                //RutonyBot.BotSay(site, "Ограбление не удалось, но грабителям удалось унести ноги.");
                            }
                        }
                    }

                    try
                    {
                        File.Delete(GlobalName.FilePathJson);
                    }
                    catch { }
                }).Start();
                return;
            }
            else
            {
                AddRobber(username, credit, site);
            }
        }