コード例 #1
0
        private bool ProcessPlugin(bool hasSetCommandQueue, ProfilePluginConfiguration pluginConfig)
        {
            IJinxBotPlugin plugin = PluginFactory.CreatePlugin(pluginConfig);

            m_activePlugins.Add(pluginConfig, plugin);

            // test if the plugin is a command queue
            ICommandQueue commandQueuePlugin = plugin as ICommandQueue;

            if (!hasSetCommandQueue && commandQueuePlugin != null)
            {
                m_client.CommandQueue = commandQueuePlugin;
                hasSetCommandQueue    = true;
            }

            // test if the plugin is a database plugin
            IJinxBotDatabase databasePlugin = plugin as IJinxBotDatabase;

            if (databasePlugin != null)
            {
                m_database = databasePlugin;
            }

            // test if the plugin is a command handler
            ICommandHandler handler = plugin as ICommandHandler;

            if (handler != null)
            {
                m_commandHandlers.Add(handler);
            }

            // test if the plugin is multi-client
            IMultiClientPlugin mcp = plugin as IMultiClientPlugin;

            if (mcp != null)
            {
                mcp.AddClient(this);
            }
            else
            {
                ISingleClientPlugin scp = plugin as ISingleClientPlugin;
                if (scp != null)
                {
                    scp.CreatePluginWindows(this.ProfileDocument);
                    scp.RegisterEvents(this);
                }
            }

            return(hasSetCommandQueue);
        }
コード例 #2
0
        public JinxBotClient(ClientProfile profile)
        {
            m_activePlugins = new Dictionary <ProfilePluginConfiguration, IJinxBotPlugin>();

            if (profile.SimulateClient)
            {
                m_client = new SimulatedBattleNetClient(profile);
            }
            else
            {
                m_client = new BattleNetClient(profile);
            }

            m_profile          = profile;
            m_resourceProvider = ProfileResourceProvider.RegisterProvider(m_client);
            m_cmdTranslator    = new CommandTranslator(this);

            bool hasSetCommandQueue = false;

            if (m_database == null)
            {
                m_database = new JinxBotDefaultDatabase();
            }

            // finally, initialize ui
            m_window = new ProfileDocument(this);

            // initialize plugins
            m_commandHandlers = new List <ICommandHandler>();
            foreach (ProfilePluginConfiguration pluginConfig in profile.PluginSettings)
            {
                hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, pluginConfig);
            }

            ProfilePluginConfiguration jsConfig = new ProfilePluginConfiguration
            {
                Assembly = "JinxBot.Plugins.Script.dll",
                Name     = "JavaScript Plugin",
                Settings = new ProfilePluginSettingConfiguration[0],
                Type     = "JinxBot.Plugins.Script.JinxBotJavaScriptPlugin"
            };

            hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, jsConfig);

            if (!hasSetCommandQueue)
            {
                m_client.CommandQueue = new TimedMessageQueue();
            }
        }
コード例 #3
0
ファイル: JinxBotClient.cs プロジェクト: Mofsy/jinxbot
        public JinxBotClient(ClientProfile profile)
        {
            m_activePlugins = new Dictionary<ProfilePluginConfiguration, IJinxBotPlugin>();

            if (profile.SimulateClient)
                m_client = new SimulatedBattleNetClient(profile);
            else
                m_client = new BattleNetClient(profile);

            m_profile = profile;
            m_resourceProvider = ProfileResourceProvider.RegisterProvider(m_client);
            m_cmdTranslator = new CommandTranslator(this);

            bool hasSetCommandQueue = false;

            if (m_database == null)
                m_database = new JinxBotDefaultDatabase();

            // finally, initialize ui
            m_window = new ProfileDocument(this);

            // initialize plugins
            m_commandHandlers = new List<ICommandHandler>();
            foreach (ProfilePluginConfiguration pluginConfig in profile.PluginSettings)
            {
                hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, pluginConfig);
            }

            ProfilePluginConfiguration jsConfig = new ProfilePluginConfiguration
            {
                Assembly = "JinxBot.Plugins.Script.dll",
                Name = "JavaScript Plugin",
                Settings = new ProfilePluginSettingConfiguration[0],
                Type = "JinxBot.Plugins.Script.JinxBotJavaScriptPlugin"
            };
            hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, jsConfig);

            if (!hasSetCommandQueue)
            {
                m_client.CommandQueue = new TimedMessageQueue();
            }
        }
コード例 #4
0
ファイル: JinxBotClient.cs プロジェクト: Mofsy/jinxbot
        private bool ProcessPlugin(bool hasSetCommandQueue, ProfilePluginConfiguration pluginConfig)
        {
            IJinxBotPlugin plugin = PluginFactory.CreatePlugin(pluginConfig);
            m_activePlugins.Add(pluginConfig, plugin);

            // test if the plugin is a command queue
            ICommandQueue commandQueuePlugin = plugin as ICommandQueue;
            if (!hasSetCommandQueue && commandQueuePlugin != null)
            {
                m_client.CommandQueue = commandQueuePlugin;
                hasSetCommandQueue = true;
            }

            // test if the plugin is a database plugin
            IJinxBotDatabase databasePlugin = plugin as IJinxBotDatabase;
            if (databasePlugin != null)
                m_database = databasePlugin;

            // test if the plugin is a command handler
            ICommandHandler handler = plugin as ICommandHandler;
            if (handler != null)
                m_commandHandlers.Add(handler);

            // test if the plugin is multi-client
            IMultiClientPlugin mcp = plugin as IMultiClientPlugin;
            if (mcp != null)
                mcp.AddClient(this);
            else
            {
                ISingleClientPlugin scp = plugin as ISingleClientPlugin;
                if (scp != null)
                {
                    scp.CreatePluginWindows(this.ProfileDocument);
                    scp.RegisterEvents(this);
                }
            }

            return hasSetCommandQueue;
        }
コード例 #5
0
ファイル: JinxMod.cs プロジェクト: Mofsy/jinxbot-plugins
        public void RegisterEvents(IJinxBotClient profileClient)
        {
            m_client = profileClient;
            m_bnet = profileClient.Client;
            m_db = profileClient.Database;

            m_bnet.RegisterUserJoinedNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserShownNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserFlagsChangedNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserLeftNotification(Priority.High, user_Left);
        }
コード例 #6
0
ファイル: JinxMod.cs プロジェクト: Mofsy/jinxbot-plugins
        public void UnregisterEvents(IJinxBotClient profileClient)
        {
            m_bnet.UnregisterUserJoinedNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserShownNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserFlagsChangedNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserLeftNotification(Priority.High, user_Left);

            m_bnet = null;
            m_client = null;
            m_db = null;
        }