Exemple #1
0
        public void Initialize(BotConfig config)
        {
            m_config = config;
            if (m_config.obswebsocket.Enabled)
            {
                m_obs = new OBSWebsocket();

                m_obs.Connected    += onConnect;
                m_obs.Disconnected += onDisconnect;

                m_obs.SceneChanged              += onSceneChange;
                m_obs.SceneCollectionChanged    += onSceneColChange;
                m_obs.ProfileChanged            += onProfileChange;
                m_obs.TransitionChanged         += onTransitionChange;
                m_obs.TransitionDurationChanged += onTransitionDurationChange;

                m_obs.StreamingStateChanged += onStreamingStateChange;
                m_obs.RecordingStateChanged += onRecordingStateChange;

                m_obs.StreamStatus += onStreamData;
                CommandServer.AddCommand(string.Empty, CommandPermissions.Viewer, "OBSIntegrationModule", true, "!uptime", "!uptime", "Display how long the stream has been online.", PrintUptime);
                CommandServer.AddCommand(string.Empty, CommandPermissions.Mod | CommandPermissions.BroadCaster | CommandPermissions.VIP | CommandPermissions.Bits100000p, "OBSIntegrationModule", true, "!scenes", "!scenes", "Lists all scenes in the current scene collection.", PrintOBSScenes);
                CommandServer.AddCommand(string.Empty, CommandPermissions.Mod | CommandPermissions.BroadCaster | CommandPermissions.VIP | CommandPermissions.Bits100000p, "OBSIntegrationModule", true, "!switchscene", "!switchscene [sceneindex]", "Switches scene to scene identified by this scene index from the !scenes command", SwitchOBSScene);

                ConnectOBS(m_obs);
            }
        }
Exemple #2
0
        public void ModulesStart()
        {
            var type  = typeof(IChatModule);
            var types = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(s => s.GetTypes())
                        .Where(p => type.IsAssignableFrom(p) && !p.IsInterface);


            foreach (var t in types)
            {
                var obj = (IChatModule)Activator.CreateInstance(t);
                var id  = Guid.NewGuid();

                if (obj.IsShared)
                {
                    m_LoadedModules.Add(id, obj);
                    m_SharedModules.Add(id, obj);
                }
                else
                {
                    m_nonSharedModulesTypes.Add(t);
                }
                if (obj.IsShared)
                {
                    Config.BotConfig neuteredConfig = new Config.BotConfig();
                    neuteredConfig.general      = m_Config.general;
                    neuteredConfig.httpserver   = m_Config.httpserver;
                    neuteredConfig.obswebsocket = m_Config.obswebsocket;
                    obj.Initialize(neuteredConfig);
                }
            }
        }
 public BaseHttpServer(Config.BotConfig pConfig)
 {
     m_Output             = BotOutput.Instance;
     m_port               = (uint)pConfig.httpserver.Port;
     m_BotConfig          = pConfig;
     m_fileRequestHandler = new FileRequest(pConfig.httpserver);
     RegisterMimeTypes(m_Mimes);
 }
        public static void TestCorrectParameters()
        {
            Config.BotConfig bot = new Config.BotConfig();
            bot.token         = "test_token";
            bot.commandPrefix = "test_prefix";

            DeleteConfig();
            Config.WriteConfig(bot);
            Config.BotConfig botRead = Config.ReadConfig();

            Assert.Equal("test_token", botRead.token);
            Assert.Equal("test_prefix", botRead.commandPrefix);
        }
Exemple #5
0
        public void ChannelJoined(object sender, TwitchChannel joinedTwitchChannel)
        {
            Dictionary <Guid, IChatModule> loadedModulesCopy;

            lock (m_LoadedModules)
            {
                loadedModulesCopy = new Dictionary <Guid, IChatModule>(m_LoadedModules);
            }
            foreach (Guid key in loadedModulesCopy.Keys)
            {
                loadedModulesCopy[key].ChannelJoined(joinedTwitchChannel);
            }
            bool NeedToCreate = true;

            lock (m_nonSharedModules)
            {
                if (!m_nonSharedModules.ContainsKey(joinedTwitchChannel.Channel))
                {
                    m_nonSharedModules.Add(joinedTwitchChannel.Channel, new Dictionary <Guid, IChatModule>());
                }
                else
                {
                    NeedToCreate = false;
                }
            }

            if (NeedToCreate)
            {
                Config.BotConfig neuteredConfig = new Config.BotConfig();
                neuteredConfig.general    = m_Config.general;
                neuteredConfig.httpserver = m_Config.httpserver;

                foreach (Type t in m_nonSharedModulesTypes)
                {
                    var obj = (IChatModule)Activator.CreateInstance(t);
                    var id  = Guid.NewGuid();
                    m_LoadedModules.Add(id, obj);
                    obj.Initialize(neuteredConfig);
                    obj.ChannelJoined(joinedTwitchChannel);
                    lock (m_nonSharedModules)
                    {
                        m_nonSharedModules[joinedTwitchChannel.Channel].Add(id, obj);
                    }
                }
                foreach (var obj in m_nonSharedModules[joinedTwitchChannel.Channel].Keys)
                {
                    m_nonSharedModules[joinedTwitchChannel.Channel][obj].Started();
                }
            }
        }
        public static void TestInvalidConfigFile()
        {
            File.WriteAllText(Config.ConfigPath, "garbage_json_format");

            Assert.Throws <Exception>(() =>
            {
                try
                {
                    Config.BotConfig bot = Config.ReadConfig();
                }

                catch (Exception ex)
                {
                    throw new Exception("[Exception]: " + ex.Message);
                }
            });
        }
        public static void TestMissingCommandPrefix()
        {
            Config.BotConfig bot = new Config.BotConfig();
            bot.token            = "test_token";
            bot.commandPrefix    = "";
            bot.bargainChannelID = 5;
            bot.scrapeDelay      = 100;
            bot.postDelay        = 200;
            bot.maxDepth         = 5;
            bot.logFile          = "test_logfile";

            DeleteConfig();
            Config.WriteConfig(bot);
            Config.BotConfig botRead = Config.ReadConfig();

            Assert.Equal("test_token", botRead.token);
            Assert.Equal("", botRead.commandPrefix);
            Assert.Equal <ulong>(5, botRead.bargainChannelID);
            Assert.Equal(100, botRead.scrapeDelay);
            Assert.Equal(200, botRead.postDelay);
            Assert.Equal(5, botRead.maxDepth);
            Assert.Equal("test_logfile", botRead.logFile);
        }
Exemple #8
0
 public ChatModuleManager(Config.BotConfig pBotConfig)
 {
     m_Config = pBotConfig;
 }