Beispiel #1
0
        /// <summary>
        /// Adds a new Project to the ProjectList. Remember to dump the configuration afterwards by calling dumpToFile()
        /// </summary>
        /// <param name="projectName">Name of the project (e.g., en.wikipedia) to add</param>
        /// <param name="interwiki">Interwiki link (e.g., it:s: -- can be empty string)</param>
        public void addNewProject(string projectName, string interwiki)
        {
            if (interwiki == "")
            {
                //Try to guess interwiki

                if (!projectName.Contains("."))
                {
                    //Cannot guess; probably something like "mediawiki"
                    throw new Exception((String)Program.msgs["20004"]);
                }

                string langPortion = projectName.Split(new char[1] { '.' }, 2)[0];
                string projPortion = projectName.Split(new char[1] { '.' }, 2)[1];
                switch (projPortion)
                {
                    case "wikipedia":
                        interwiki = langPortion + ":";
                        break;
                    case "wiktionary":
                        interwiki = "wikt:" + langPortion + ":";
                        break;
                    case "wikibooks":
                        interwiki = "b:" + langPortion + ":";
                        break;
                    case "wikinews":
                        interwiki = "n:" + langPortion + ":";
                        break;
                    case "wikisource":
                        interwiki = "s:" + langPortion + ":";
                        break;
                    case "wikiquote":
                        interwiki = "q:" + langPortion + ":";
                        break;
                    case "wikiversity":
                        interwiki = "v:" + langPortion + ":";
                        break;
                    default:
                        throw new Exception((String)Program.msgs["20004"]);
                }
            }

            if (this.ContainsKey(projectName))
                throw new Exception(Program.getFormatMessage(16400, projectName));

            logger.Info("Registering new project " + projectName + " with interwiki " + interwiki);
            Project prj = new Project();
            prj.projectName = projectName;
            prj.interwikiLink = interwiki;
            prj.rooturl = "http://" + projectName + ".org/";
            prj.retrieveWikiDetails();
            this.Add(projectName, prj);
            //Join the new channel:
            logger.Info("Joining #" + projectName);
            Program.rcirc.rcirc.RfcJoin("#" + projectName);

            //Dump new settings:
            dumpToFile();
        }
Beispiel #2
0
        public void reloadAllWikis()
        {
            Thread.CurrentThread.Name = "ReloadAll";

            Program.SendMessageF(Meebey.SmartIrc4net.SendType.Message, currentBatchReloadChannel
                                 , "Request to reload all " + this.Count.ToString() + " wikis accepted.", false, true);

            foreach (DictionaryEntry dicent in this)
            {
                Project prj = (Project)dicent.Value;
                prj.retrieveWikiDetails();
                Thread.Sleep(600);
            }

            //Dump new settings:
            dumpToFile();

            Program.SendMessageF(Meebey.SmartIrc4net.SendType.Message, currentBatchReloadChannel
                                 , "Reloaded all wikis. Phew, give the Wikimedia servers a break :(", false, false);
        }
Beispiel #3
0
        /// <summary>
        /// Adds a new Project to the ProjectList. Remember to dump the configuration afterwards by calling dumpToFile()
        /// </summary>
        /// <param name="projectName">Name of the project (e.g., en.wikipedia) to add</param>
        /// <param name="interwiki">Interwiki link (e.g., it:s: -- can be empty string)</param>
        public void addNewProject(string projectName, string interwiki)
        {
            if (interwiki == "")
            {
                //Try to guess interwiki

                if (!projectName.Contains("."))
                {
                    //Cannot guess; probably something like "mediawiki"
                    throw new Exception((String)Program.msgs["20004"]);
                }

                string langPortion = projectName.Split(new char[1] {
                    '.'
                }, 2)[0];
                string projPortion = projectName.Split(new char[1] {
                    '.'
                }, 2)[1];
                switch (projPortion)
                {
                case "wikipedia":
                    interwiki = langPortion + ":";
                    break;

                case "wiktionary":
                    interwiki = "wikt:" + langPortion + ":";
                    break;

                case "wikibooks":
                    interwiki = "b:" + langPortion + ":";
                    break;

                case "wikinews":
                    interwiki = "n:" + langPortion + ":";
                    break;

                case "wikisource":
                    interwiki = "s:" + langPortion + ":";
                    break;

                case "wikiquote":
                    interwiki = "q:" + langPortion + ":";
                    break;

                case "wikiversity":
                    interwiki = "v:" + langPortion + ":";
                    break;

                default:
                    throw new Exception((String)Program.msgs["20004"]);
                }
            }

            if (this.ContainsKey(projectName))
            {
                throw new Exception(Program.getFormatMessage(16400, projectName));
            }

            logger.Info("Registering new project " + projectName + " with interwiki " + interwiki);
            Project prj = new Project();

            prj.projectName   = projectName;
            prj.interwikiLink = interwiki;
            prj.rooturl       = "http://" + projectName + ".org/";
            prj.retrieveWikiDetails();
            this.Add(projectName, prj);
            //Join the new channel:
            logger.Info("Joining #" + projectName);
            Program.rcirc.rcirc.RfcJoin("#" + projectName);

            //Dump new settings:
            dumpToFile();
        }