예제 #1
0
파일: Program.cs 프로젝트: bin101/SFBoty
        static void Main(string[] args)
        {
            ChatLogs = new Dictionary <string, HashSet <string> >();

            List <AccountSettings> accountSettings = new List <AccountSettings>();

            accountSettings = LoadSettings();

            List <Account> accounts = new List <Account>();

            accountSettings.ForEach(s => accounts.Add(new Account(s)));

            List <Bot> bots = new List <Bot>();

            foreach (Account a in accounts)
            {
                Bot bot = new Bot(a);
                bot.MessageOutput += new EventHandler <MessageEventsArgs>(bot_MessageOutput);
                bot.ExtendedLog   += new EventHandler <MessageEventsArgs>(bot_ExtendedLog);
                bot.Error         += new EventHandler <MessageEventsArgs>(bot_Error);

                bot.AddMenu(new LoginArea());
                bot.AddMenu(new MagicShopArea());
                bot.AddMenu(new WeaponShopArea());
                bot.AddMenu(new MountArea());
                bot.AddMenu(new TavernArea());
                bot.AddMenu(new ToiletArea());
                bot.AddMenu(new ArenaArea());
                bot.AddMenu(new GuildArea());
                bot.AddMenu(new CharScreenArea());
                bot.AddMenu(new DungeonArea());
                bot.AddMenu(new TownwatchArea());
                bot.AddMenu(new SinglePortalArea());

                bots.Add(bot);
            }

            Console.WriteLine(DateTime.Now.ToString() + ": Bot wurde gestartet");
            ClearLogs();

            bots.ForEach(b => b.Run());

            string command = "";

            while (command != "exit")
            {
                command = Console.ReadLine();

                switch (command.ToLower())
                {
                case "exit":
                    bots.ForEach(b => b.Stop());
                    break;

                case "help":
                    Console.WriteLine("Folgende Befehlt gibt es: exit, sleep, help");
                    break;

                case "sleep":
                    Console.WriteLine("use: [sleep]_[server]_[user]_[timeMinute]");
                    break;

                default:
                    Console.WriteLine("Ungültiger Befehl versuche es mit dem Befehl \"help\"");
                    break;
                }

                if (command.StartsWith("sleep "))
                {
                    string[] commandParts = command.Split(' ');
                    if (commandParts.Count() == 4)
                    {
                        List <Bot> tmp = bots.Where(b => b.Account.Settings.Username.ToLower() == commandParts[2].ToLower() && b.Account.Settings.Server.ToLower() == commandParts[1].ToLower()).ToList();
                        if (tmp.Count > 0)
                        {
                            Bot bot = tmp.First();
                            if (bot != null)
                            {
                                bot.Break(Convert.ToSingle(commandParts[3]) * 60f);
                                Console.WriteLine(string.Concat("Bot ", bot.Account.Settings.Server, " ", bot.Account.Settings.Username, " unterbricht"));
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        private void StartOneBot(Account acc)
        {
            string key = String.Concat(acc.Settings.Username, acc.Settings.Server);

            if (Bots.Keys.Any(x => x == key))
            {
                Bots[key].Run();
            }
            else
            {
                Bot bot = new Bot(acc);
                bot.MessageOutput += new EventHandler <MessageEventsArgs>(bot_MessageOutput);
                bot.ExtendedLog   += new EventHandler <MessageEventsArgs>(bot_ExtendedLog);
                bot.Error         += new EventHandler <MessageEventsArgs>(bot_Error);

                bot.AddMenu(new LoginArea());
                bot.AddMenu(new MagicShopArea());
                bot.AddMenu(new WeaponShopArea());
                bot.AddMenu(new MountArea());
                bot.AddMenu(new TavernArea());
                bot.AddMenu(new ToiletArea());
                bot.AddMenu(new ArenaArea());
                bot.AddMenu(new GuildArea());
                bot.AddMenu(new CharScreenArea());
                bot.AddMenu(new DungeonArea());
                bot.AddMenu(new TownwatchArea());
                bot.AddMenu(new SinglePortalArea());

                Bots.Add(key, bot);
                Bots[key].Run();
            }
        }