Remove() public méthode

Remove all refs
public Remove ( ) : void
Résultat void
Exemple #1
0
        /// <summary>
        /// Part a channel
        /// </summary>
        /// <param name="channel">Channel object</param>
        /// <param name="user">User</param>
        /// <param name="host">Host</param>
        /// <param name="message">Message</param>
        /// <param name="origin"></param>
        public static void PartChannel(Channel channel, string user, string host, string message, string origin = "NULL")
        {
            try
            {
                if (origin == "NULL")
                {
                    origin = channel.Name;
                }
                if (channel.Name == Configuration.System.DebugChan && (message == Configuration.System.CommandPrefix + "part"
                                                          || message == Configuration.System.CommandPrefix + "drop"))
                {
                    channel.PrimaryInstance.irc.Queue.DeliverMessage("Cowardly refusing to part this channel, because I love it :3", channel);
                    return;
                }
                if (message == Configuration.System.CommandPrefix + "drop")
                {
                    if (channel.SystemUsers.IsApproved(user, host, "admin"))
                    {
                        while (!Core.FinishedJoining)
                        {
                            Syslog.Log("Postponing request to part " + channel.Name + " because bot is still loading", true);
                            Thread.Sleep(2000);
                        }
                        channel.PrimaryInstance.irc.SendData("PART " + channel.Name + " :" + "dropped by " + user + " from " + origin);
                        Syslog.Log("Dropped " + channel.Name + " dropped by " + user + " from " + origin);
                        Thread.Sleep(100);
                        try
                        {
                            File.Delete(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".xml");
                            lock (ExtensionHandler.Extensions)
                            {
                                foreach (Module curr in ExtensionHandler.Extensions)
                                {
                                    try
                                    {
                                        if (curr.IsWorking)
                                        {
                                            curr.Hook_ChannelDrop(channel);
                                        }
                                    }
                                    catch (Exception fail)
                                    {
                                        Syslog.Log("MODULE: exception at Hook_ChannelDrop in " + curr.Name, true);
                                        Core.HandleException(fail, curr.Name);
                                    }
                                }
                            }
                        }
                        catch (Exception fail)
                        {
                            Core.HandleException(fail);
                        }
                        lock (Configuration.Channels)
                        {
                            channel.Remove();
                            Configuration.Channels.Remove(channel);
                        }
                        Configuration.Save();
                        return;
                    }
                    Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), origin);
                    return;
                }

                if (message == Configuration.System.CommandPrefix + "part")
                {
                    if (channel.SystemUsers.IsApproved(user, host, "admin"))
                    {
                        while (!Core.FinishedJoining)
                        {
                            Syslog.Log("Postponing request to part " + channel.Name + " because bot is still loading", true);
                            Thread.Sleep(2000);
                        }
                        channel.PrimaryInstance.irc.SendData("PART " + channel.Name + " :" + "removed by " + user + " from " + origin);
                        Syslog.Log("Removed " + channel.Name + " removed by " + user + " from " + origin);
                        Thread.Sleep(100);
                        lock (Configuration.Channels)
                        {
                            channel.Remove();
                            Configuration.Channels.Remove(channel);
                        }
                        Configuration.Save();
                        return;
                    }
                    Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), origin);
                }
            }
            catch (Exception fail)
            {
                Core.HandleException(fail);
            }
        }
Exemple #2
0
        /// <summary>
        /// Part a channel
        /// </summary>
        /// <param name="channel">Channel object</param>
        /// <param name="user">User</param>
        /// <param name="host">Host</param>
        /// <param name="message">Message</param>
        /// <param name="origin">The channel from which this request was sent</param>
        public static void PartChannel(Channel channel, string user, string host, string message, string origin = "NULL")
        {
            try
            {
                if (origin == "NULL")
                {
                    origin = channel.Name;
                }
                if (channel.Name == Configuration.System.DebugChan && (message == Configuration.System.CommandPrefix + "part" ||
                                                                       message == Configuration.System.CommandPrefix + "drop"))
                {
                    IRC.DeliverMessage("Cowardly refusing to part this channel, because I love it :3", channel);
                    return;
                }
                if (message == Configuration.System.CommandPrefix + "drop")
                {
                    if (channel.SystemUsers.IsApproved(user, host, "drop"))
                    {
                        while (!IRC.FinishedJoining)
                        {
                            Syslog.Log("Postponing request to part " + channel.Name + " because bot is still loading", true);
                            Thread.Sleep(2000);
                        }
                        channel.PrimaryInstance.Network.Transfer("PART " + channel.Name + " :" + "dropped by " + user + " from " + origin);
                        Syslog.Log("Dropped " + channel.Name + " dropped by " + user + " from " + origin);
                        Thread.Sleep(100);
                        try
                        {
                            File.Delete(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".xml");
                        }
                        catch (Exception fail)
                        {
                            Syslog.ErrorLog("Failed to delete configuration file of " + channel.Name);
                            Core.HandleException(fail);
                        }
                        foreach (Module module in ExtensionHandler.ExtensionList)
                        {
                            try
                            {
                                if (module.IsWorking)
                                {
                                    module.Hook_ChannelDrop(channel);
                                }
                            }
                            catch (Exception fail)
                            {
                                Syslog.Log("MODULE: exception at Hook_ChannelDrop in " + module.Name, true);
                                Core.HandleException(fail, module.Name);
                            }
                        }
                        lock (Configuration.Channels)
                        {
                            channel.Remove();
                        }
                        Configuration.Save();
                        return;
                    }
                    IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), origin);
                    return;
                }

                if (message == Configuration.System.CommandPrefix + "part")
                {
                    if (channel.SystemUsers.IsApproved(user, host, "part"))
                    {
                        while (!IRC.FinishedJoining)
                        {
                            Syslog.Log("Postponing request to part " + channel.Name + " because bot is still loading", true);
                            Thread.Sleep(2000);
                        }
                        channel.PrimaryInstance.Network.Transfer("PART " + channel.Name + " :" + "removed by " + user + " from " + origin);
                        Syslog.Log("Removed " + channel.Name + " removed by " + user + " from " + origin);
                        Thread.Sleep(100);
                        lock (Configuration.Channels)
                        {
                            channel.Remove();
                        }
                        channel.SaveConfig();
                        Configuration.Save();
                        return;
                    }
                    IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), origin);
                }
            }
            catch (Exception fail)
            {
                Core.HandleException(fail);
            }
        }
Exemple #3
0
        /// <summary>
        /// Part a channel
        /// </summary>
        /// <param name="channel">Channel object</param>
        /// <param name="user">User</param>
        /// <param name="host">Host</param>
        /// <param name="message">Message</param>
        /// <param name="origin">The channel from which this request was sent</param>
        public static void PartChannel(Channel channel, string user, string host, string message, string origin = "NULL")
        {
            try
            {
                if (origin == "NULL")
                    origin = channel.Name;
                if (channel.Name == Configuration.System.DebugChan && (message == Configuration.System.CommandPrefix + "part"
                                                          || message == Configuration.System.CommandPrefix + "drop"))
                {
                    IRC.DeliverMessage("Cowardly refusing to part this channel, because I love it :3", channel);
                    return;
                }
                if (message == Configuration.System.CommandPrefix + "drop")
                {
                    if (channel.SystemUsers.IsApproved(user, host, "drop"))
                    {
                        while (!IRC.FinishedJoining)
                        {
                            Syslog.Log("Postponing request to part " + channel.Name + " because bot is still loading", true);
                            Thread.Sleep(2000);
                        }
                        channel.PrimaryInstance.Network.Transfer("PART " + channel.Name + " :" + "dropped by " + user + " from " + origin);
                        Syslog.Log("Dropped " + channel.Name + " dropped by " + user + " from " + origin);
                        Thread.Sleep(100);
                        try
                        {
                            File.Delete(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".xml");
                        }
                        catch (Exception fail)
                        {
                            Syslog.ErrorLog("Failed to delete configuration file of " + channel.Name);
                            Core.HandleException(fail);
                        }
                        foreach (Module module in ExtensionHandler.ExtensionList)
                        {
                            try
                            {
                                if (module.IsWorking)
                                    module.Hook_ChannelDrop(channel);
                            }
                            catch (Exception fail)
                            {
                                Syslog.Log("MODULE: exception at Hook_ChannelDrop in " + module.Name, true);
                                Core.HandleException(fail, module.Name);
                            }
                        }
                        lock (Configuration.Channels)
                        {
                            channel.Remove();
                        }
                        Configuration.Save();
                        return;
                    }
                    IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), origin);
                    return;
                }

                if (message == Configuration.System.CommandPrefix + "part")
                {
                    if (channel.SystemUsers.IsApproved(user, host, "part"))
                    {
                        while (!IRC.FinishedJoining)
                        {
                            Syslog.Log("Postponing request to part " + channel.Name + " because bot is still loading", true);
                            Thread.Sleep(2000);
                        }
                        channel.PrimaryInstance.Network.Transfer("PART " + channel.Name + " :" + "removed by " + user + " from " + origin);
                        Syslog.Log("Removed " + channel.Name + " removed by " + user + " from " + origin);
                        Thread.Sleep(100);
                        lock (Configuration.Channels)
                        {
                            channel.Remove();
                            if (origin != channel.Name)
                                IRC.DeliverMessage("Successfully parted channel: " + channel.Name, origin);
                        }
                        channel.SaveConfig();
                        Configuration.Save();
                        return;
                    }
                    IRC.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), origin);
                }
            }
            catch (Exception fail)
            {
                Core.HandleException(fail);
            }
        }