Example #1
0
        static void Main(string[] args)
        {
            foreach (var line in File.ReadLines("config.txt"))
            {
                var indexOfSep = line.IndexOf('=');
                var key = line.Substring(0,indexOfSep).Trim();
                var val = line.Substring(indexOfSep + 1).Trim();

                if (key == "user") User = val;
                if (key == "pass") Pass = val;
                if (key == "apiAuthentication") ApiAuthentication = val;
            }

            if (string.IsNullOrEmpty(User) || string.IsNullOrEmpty(Pass) || string.IsNullOrEmpty(ApiAuthentication))
            {
                Console.WriteLine("Incomplete config");
                return;
            }

            var statusApi = new StatusApi();
            statusApi.SetStatus(false);

            var s = new Site("http://wiki-de.guildwars2.com/wiki/", User, Pass);

            if (args.Contains("-generatePagelist") || !File.Exists("pagelist.txt"))
            {
                Console.WriteLine("Generating pagelist...");
                var pagelist = new PageList(s);
                pagelist.FillFromCategoryTree("Guild Wars 2");
                pagelist.SaveTitlesToFile("pagelist.txt");
            }

            try
            {
                Run(s);
            }
            finally
            {
                statusApi.SetStatus(false);
            }
        }
Example #2
0
        public void Run()
        {
            Start();
            var statusApi = new StatusApi();
            statusApi.SetStatus(true);
            try
            {
                var i = 0;
                lock(Pages) foreach (Page p in Pages.OrderBy(p => p.title).Skip(0))
                {
                    if (!statusApi.GetRunning())
                    {
                        Console.WriteLine("Canceled by status api");
                        return;
                    }

                    var editStatus = new EditStatus();
                    ProcessPage(p, editStatus);

                    if (editStatus.Save)
                    {
                        p.Save("[Bot] " + editStatus.EditComment, true);
                        p.LoadEx();
                        statusApi.AddEdit(p.title, p.lastRevisionID, editStatus.EditComment);
                        Thread.Sleep(10000);
                    }

                    Console.Title = string.Format("({0}/{1})", ++i, Pages.Count());
                }
            }
            finally
            {
                statusApi.SetStatus(false);
                End();
            }
        }