Esempio n. 1
0
        private void Bot_OnMessageRecieve(IRCBot sender, MBotMessage message)
        {
            bool   hasParamiter = message.Text.Contains(" ");
            string uCmd         = string.Empty;

            string[] Parameters = new string[] {  };
            if (hasParamiter)
            {
                uCmd       = message.Text.Split(' ')[0];
                Parameters = message.Text.Split(new char[] { ' ' }, 2)[1].Split(' ');
            }
            else
            {
                uCmd = message.Text;
            }
            foreach (ListViewItem i in listView1.Items)
            {
                RegisteredCommand command = (RegisteredCommand)i.Tag;
                if (command == null)
                {
                    continue;
                }
                if (command.IsModOnly && !Moderators.Contains(message.Sender.ToLower()))
                {
                    continue;
                }
                if (command.Handler.Command.Paramiter == ParamiterType.Must && !hasParamiter)
                {
                    continue;
                }
                if (command.CheckFlag(message))
                {
                    command.Execute(message.Sender, Parameters);
                }
            }

            foreach (var plugin in PluginList)
            {
                if (plugin.Permissions.CanUseChatTrigger)
                {
                    plugin.Permissions.Handlers.ChatTrigger.CheckTrigger(plugin, message.Sender, message.Text);
                }
            }
        }
Esempio n. 2
0
 private void Bot_OnDisconnect(IRCBot sender)
 {
     MessageBox.Show("Bot lost connection.");
 }
Esempio n. 3
0
        public MainWindow()
        {
            using (LoadBotForm lbf = new LoadBotForm())
            {
                if (lbf.ShowDialog() != DialogResult.OK)
                {
                    Environment.Exit(0);
                    return;
                }
                bot = new IRCBot(lbf.BotLogin);
            }
            InitializeComponent();

            DirectoryInfo PluginDirectory;

            try
            {
                PluginDirectory = new DirectoryInfo("Plugins");
                if (!PluginDirectory.Exists)
                {
                    PluginDirectory.Create();
                }
            }
            catch
            {
                MessageBox.Show("No access to \"Plugin\" Directory.");
                return;
            }
            foreach (FileInfo pluginFile in PluginDirectory.GetFiles("*.dll"))
            {
                try
                {
                    LoadedPlugin plugin = PluginHandler.LoadPlugin(pluginFile.FullName);
                    plugin.OnException += Plugin_OnException;
                    if (!PluginIDList.Add(plugin.PluginID))
                    {
                        throw new Exception("Duplicate id");
                    }

                    HandlerBundle handlers = new HandlerBundle();

                    handlers.Bot               = new BotHandler(plugin);
                    handlers.Bot.OnException  += OnException;
                    handlers.Bot.OnSayMessage += Bot_OnSayMessage;

                    handlers.UI           = new BotUIHandler(plugin);
                    handlers.UI.OnTabAdd += UI_OnTabAdd;

                    plugin.Initilze(handlers);


                    foreach (var command in plugin.Details.LoadedCommands)
                    {
                        var handler = new CommandHandler(plugin, command);
                        if (!HandlerList.ContainsKey(handler.ID))
                        {
                            HandlerList.Add(handler.ID, handler);
                        }
                    }


                    PluginDisplayControl display = new PluginDisplayControl(plugin);
                    display.Parent   = PluginDisplayPanel;
                    display.Width    = PluginDisplayPanel.Width;
                    display.Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                    display.Location = new Point(0, PluginList.Count * display.Height);
                    PluginDisplayPanel.Controls.Add(display);

                    PluginList.Add(plugin);
                }
                catch
                {
                    Debug.WriteLine("Error on file {0}", pluginFile.Name);
                }

                LoadSettings();
            }
        }
Esempio n. 4
0
        public MainWindow()
        {
            using (LoadBotForm lbf = new LoadBotForm())
            {
                if(lbf.ShowDialog() != DialogResult.OK)
                {
                    Environment.Exit(0);
                    return;
                }
                bot = new IRCBot(lbf.BotLogin);
            }
            InitializeComponent();

            DirectoryInfo PluginDirectory;
            try
            {
                PluginDirectory = new DirectoryInfo("Plugins");
                if (!PluginDirectory.Exists)
                    PluginDirectory.Create();
            }
            catch
            {
                MessageBox.Show("No access to \"Plugin\" Directory.");
                return;
            }
            foreach (FileInfo pluginFile in PluginDirectory.GetFiles("*.dll"))
            {
                try
                {
                    LoadedPlugin plugin = PluginHandler.LoadPlugin(pluginFile.FullName);
                    plugin.OnException += Plugin_OnException;
                    if (!PluginIDList.Add(plugin.PluginID))
                        throw new Exception("Duplicate id");

                    HandlerBundle handlers = new HandlerBundle();

                    handlers.Bot = new BotHandler(plugin);
                    handlers.Bot.OnException += OnException;
                    handlers.Bot.OnSayMessage += Bot_OnSayMessage;

                    handlers.UI = new BotUIHandler(plugin);
                    handlers.UI.OnTabAdd += UI_OnTabAdd;

                    plugin.Initilze(handlers);

                    foreach (var command in plugin.Details.LoadedCommands)
                    {
                        var handler = new CommandHandler(plugin, command);
                        if (!HandlerList.ContainsKey(handler.ID))
                        {
                            HandlerList.Add(handler.ID, handler);
                        }
                    }

                    PluginDisplayControl display = new PluginDisplayControl(plugin);
                    display.Parent = PluginDisplayPanel;
                    display.Width = PluginDisplayPanel.Width;
                    display.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                    display.Location = new Point(0, PluginList.Count * display.Height);
                    PluginDisplayPanel.Controls.Add(display);

                    PluginList.Add(plugin);
                }
                catch
                {
                    Debug.WriteLine("Error on file {0}", pluginFile.Name);
                }

                LoadSettings();
            }
        }
Esempio n. 5
0
        private void Bot_OnMessageRecieve(IRCBot sender, MBotMessage message)
        {
            bool hasParamiter = message.Text.Contains(" ");
            string uCmd = string.Empty;
            string[] Parameters = new string[] {  };
            if (hasParamiter)
            {
                uCmd = message.Text.Split(' ')[0];
                Parameters = message.Text.Split(new char[] {' '}, 2)[1].Split(' ');
            }
            else
            {
                uCmd = message.Text;
            }
            foreach(ListViewItem i in listView1.Items)
            {
                RegisteredCommand command = (RegisteredCommand)i.Tag;
                if (command == null)
                    continue;
                if (command.IsModOnly && !Moderators.Contains(message.Sender.ToLower()))
                    continue;
                if (command.Handler.Command.Paramiter == ParamiterType.Must && !hasParamiter)
                    continue;
                if (command.CheckFlag(message))
                    command.Execute(message.Sender, Parameters);
            }

            foreach(var plugin in PluginList)
            {
                if (plugin.Permissions.CanUseChatTrigger)
                    plugin.Permissions.Handlers.ChatTrigger.CheckTrigger(plugin, message.Sender, message.Text);
            }
        }
Esempio n. 6
0
 private void Bot_OnDisconnect(IRCBot sender)
 {
     MessageBox.Show("Bot lost connection.");
 }