Пример #1
0
        private void ActivateCommand(object sender, IrcEventArgs e)
        {
            var sendto = (string.IsNullOrEmpty(e.Data.Channel)) ? e.Data.Nick : e.Data.Channel;

            if (e.Data.MessageArray.Length < 2)
            {
                SendMessage(SendType.Message, sendto, "Too few arguments! Try !help.");
                return;
            }

            var calledPlugins = new List <AbstractPlugin>();

            foreach (var plugin in e.Data.MessageArray.Skip(1).Select(p => new Wildcard(p)).SelectMany(wildcard => PlugManager.Plugins.Where(p => wildcard.IsMatch(p.FullName) || wildcard.IsMatch(p.MainClass))))
            {
                if (!plugin.Active)
                {
                    var plug = new Plugin.Database.Huffelpuff.Plugin {
                        PluginName = plugin.FullName
                    };
                    MainBotData.Plugin.InsertOnSubmit(plug);
                    MainBotData.SubmitChanges();

                    plugin.Activate();
                }
                calledPlugins.Add(plugin);
            }
            foreach (var line in calledPlugins.Select(plugin => "" + plugin.FullName + " [" + ((plugin.Active ? IrcConstants.IrcColor + "" + (int)IrcColors.LightGreen + "ON" : IrcConstants.IrcColor + "" + (int)IrcColors.LightRed + "OFF")) + IrcConstants.IrcColor + "]").ToLines(350, ", ", "Plugins: ", " END."))
            {
                SendMessage(SendType.Message, sendto, line);
            }
        }
Пример #2
0
        private void ActivateCommand(object sender, IrcEventArgs e)
        {
            var sendto = (string.IsNullOrEmpty(e.Data.Channel)) ? e.Data.Nick : e.Data.Channel;
            if (e.Data.MessageArray.Length < 2)
            {
                SendMessage(SendType.Message, sendto, "Too few arguments! Try !help.");
                return;
            }

            var calledPlugins = new List<AbstractPlugin>();
            foreach (var plugin in e.Data.MessageArray.Skip(1).Select(p => new Wildcard(p)).SelectMany(wildcard => PlugManager.Plugins.Where(p => wildcard.IsMatch(p.FullName) || wildcard.IsMatch(p.MainClass))))
            {
                if (!plugin.Active)
                {
                    var plug = new Plugin.Database.Huffelpuff.Plugin { PluginName = plugin.FullName };
                    MainBotData.Plugin.InsertOnSubmit(plug);
                    MainBotData.SubmitChanges();

                    plugin.Activate();
                }
                calledPlugins.Add(plugin);
            }
            foreach (var line in calledPlugins.Select(plugin => "" + plugin.FullName + " [" + ((plugin.Active ? IrcConstants.IrcColor + "" + (int)IrcColors.LightGreen + "ON" : IrcConstants.IrcColor + "" + (int)IrcColors.LightRed + "OFF")) + IrcConstants.IrcColor + "]").ToLines(350, ", ", "Plugins: ", " END."))
            {
                SendMessage(SendType.Message, sendto, line);
            }
        }