Beispiel #1
0
        static void Main(string[] args)
        {
            var ioc = new IoC();

            ioc.RegisterShared <ILogger, ConsoleLogger>();
            ioc.RegisterShared <ITwitchUserStore, TwitchUserStore>();

            ioc.RegisterCustomShared <IAppSettings>(() => new AppSettingsProvider().Get());
            ioc.RegisterShared <IWitcher3, Witcher3GameIntegration>();
            ioc.RegisterShared <IGameCommandFactory, Witcher3CommandFactory>();
            ioc.RegisterShared <IGameIntegrator, Witcher3GameIntegrator>();

            ioc.Register <IGameConnection, TcpGameConnection>();
            ioc.Register <IGameClient, TcpGameClient>();

            ioc.RegisterShared <IMessageBus, MessageBus>();

            var commandHandler = new TextCommandHandler(ioc);

            commandHandler.Register <Witcher3CommandProcessor>("witcher3", "witcher", "w3");
            commandHandler.Register <CreditsCommandProcessor>("credit", "credits", "points");

            var channelProvider     = new DefaultChannelProvider();
            var credentialsProvider = new DefaultConnectionCredentialsProvider(ioc.Resolve <IAppSettings>());

            var gameIntegrator = ioc.Resolve <IGameIntegrator>();

            gameIntegrator.Start();
        }
Beispiel #2
0
        public void Setup()
        {
            this.repository  = new Mock <IRepository <TextCommand> >();
            this.replyLoader = new Mock <ITextCommandReplyLoader>();

            this.twitchClient = new Mock <ITwitchClient>();
            this.chatCommand  = new Mock <IChatCommand>();

            this.handler = new TextCommandHandler(this.repository.Object, this.replyLoader.Object);
        }
            protected override int IndexOfCommandEnd(Buffer buffer)
            {
                if (buffer == null)
                {
                    return(-1);
                }
                if (buffer.Size == 0)
                {
                    return(-1);
                }
                List <string> commandDelimiters = new List <string>();

                for (int i = 0; i < this.Count; i++)
                {
                    TextCommandHandler tch = this[i];
                    if (tch.Enabled)
                    {
                        if (!commandDelimiters.Contains(tch.CmdDelimiter))
                        {
                            commandDelimiters.Add(tch.CmdDelimiter);
                        }
                    }
                }
                if (!commandDelimiters.Contains("\r\n"))
                {
                    commandDelimiters.Add("\r\n");
                }
                if (!commandDelimiters.Contains("\n"))
                {
                    commandDelimiters.Add("\n");
                }
                if (!commandDelimiters.Contains("\r"))
                {
                    commandDelimiters.Add("\r");
                }
                int TempResult = buffer.IndexOf(commandDelimiters[0]);

                commandDelimiters.RemoveAt(0);
                while (TempResult == -1 &&
                       commandDelimiters.Count > 0)
                {
                    TempResult = buffer.IndexOf(commandDelimiters[0]);
                    commandDelimiters.RemoveAt(0);
                }
                while (commandDelimiters.Count > 0)
                {
                    int TempInt2 = buffer.IndexOf(commandDelimiters[0]);
                    if (TempInt2 > -1)
                    {
                        TempResult = Math.Min(TempResult, TempInt2);
                    }
                    commandDelimiters.RemoveAt(0);
                }
                return(TempResult);
            }