Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="wmib.Channel"/> class.
        /// </summary>
        /// <param name='name'>
        /// Name.
        /// </param>
        public Channel(string name)
        {
            Name = name;
            Suppress = false;
            SystemUsers = new Security(this);
            LoadConfig();
            if (DefaultInstance == "any")
            {
                PrimaryInstance = Instance.GetInstance();
                // we need to save the instance so that next time bot reconnect to bouncer it uses the same instance
                DefaultInstance = PrimaryInstance.Nick;
                SaveConfig();
            }
            else
            {
                if (!Instance.Instances.ContainsKey(DefaultInstance))
                {
                    Syslog.WarningLog("There is no instance " + DefaultInstance + " reassigning channel " + this.Name +
                                      " to a different instance");
                    this.PrimaryInstance = Instance.GetInstance();
                    Syslog.Log("Reassigned to " + this.PrimaryInstance.Nick);
                }
                else
                {
                    PrimaryInstance = Instance.Instances[DefaultInstance];
                }
            }
            if (!Directory.Exists(Configuration.WebPages.HtmlPath))
                Directory.CreateDirectory(Configuration.WebPages.HtmlPath);

            foreach (Module module in ExtensionHandler.ExtensionList)
            {
                try
                {
                    if (module.IsWorking)
                    {
                        Channel self = this;
                        module.Hook_Channel(self);
                    }
                }
                catch (Exception fail)
                {
                    Syslog.Log("MODULE: exception at Hook_Channel in " + module.Name, true);
                    Core.HandleException(fail);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Remove all refs
 /// </summary>
 public void Remove()
 {
     if (IsRemoved)
     {
         Syslog.DebugLog("Channel is already removed");
         return;
     }
     SystemUsers = null;
     lock (ExtensionData)
     {
         ExtensionData.Clear();
     }
     lock (ExtensionObjects)
     {
         ExtensionObjects.Clear();
     }
     SharedDB = null;
     SharedChans.Clear();
     SharedLinkedChan.Clear();
     if (Configuration.Channels.Contains(this))
         Configuration.Channels.Remove(this);
 }
Beispiel #3
0
 public static string GetNameOfRole(Security.Role role)
 {
     lock (Security.Roles)
     {
         foreach (KeyValuePair<string, Security.Role> xx in Security.Roles)
         {
             if (role == xx.Value)
                 return xx.Key;
         }
     }
     return "{unknown role}";
 }