Пример #1
0
        private string TryFlippingLightswitch(string[] inputs)
        {
            string message = "Try including an object to interact with after the verb.";

            if (CommandProcessingService.ValidateNoun(inputs))
            {
                string noun = inputs[1];
                switch (noun)
                {
                case "light":
                case "lights":
                case "lightswitch":
                case "switch":
                    message = ToggleLights();
                    break;

                default:
                    message = "Try including the title of the object you wish \n"
                              + "to interact with.";
                    break;
                }
            }

            return(message);
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            foreach (var token in await _apiTokenData.GetAllKeys())
            {
                _logger.Info($"Setting up discord client for Server {token.ServerName}");

                _discordSocketClient = new DiscordSocketClient(new DiscordSocketConfig
                {
                    MessageCacheSize    = 0,
                    ExclusiveBulkDelete = true,
                    AlwaysDownloadUsers = true,

                    GatewayIntents =
                        GatewayIntents.Guilds |
                        GatewayIntents.GuildMembers |
                        GatewayIntents.GuildMessageReactions |
                        GatewayIntents.GuildMessages |
                        GatewayIntents.GuildVoiceStates
                });

                _discordSocketClient.Log += message =>
                {
                    if (message.Exception != null)
                    {
                        _logger.Warn($"DiscordClient: {message.Message} - {message.Exception.Message}");
                    }
                    else
                    {
                        _logger.Info($"DiscordClient: {message.Message}");
                    }
                    return(Task.CompletedTask);
                };
                _discordSocketClient.Ready += () =>
                {
                    _logger.Info($"Discord client for {token.ServerName} is ready");
                    return(Task.CompletedTask);
                };

                _discordSocketClient.Disconnected += exception =>
                {
                    _logger.Error($"Discord Client disconnected: {exception.Message}");
                    return(Task.CompletedTask);
                };
                //TODO handle disconnected event and try to reconnect


                await _discordSocketClient.LoginAsync(TokenType.Bot, token.ApiKey);

                await _discordSocketClient.StartAsync();

                _discordInterface         = new DiscordInterface(_discordSocketClient);
                _commandProcessingService = new CommandProcessingService(_discordInterface, _schedulerFactory, _activityMonitor);
                await _commandProcessingService.StartAsync(CancellationToken.None);

                //TODO when monitoring users in channels create that service here

                break; //TODO only use 1 server at a time for now
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            //Console.BackgroundColor = ConsoleColor.DarkBlue;
            //Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();

            Console.WriteLine(OutputText.Logo);
            OutputText.ShowStatusText();

            Console.WriteLine($"Passed args as command: {string.Join(" ", args)}");
            Console.WriteLine();

            cps = new CommandProcessingService(args);

            //begin the CLI
            cps.ReadCommand();
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();

            _SerialPort          = new SerialPort();
            _ModuleConfiguration = new ModuleConfiguration();
            _CommandProcessor    = new CommandProcessingService(_SerialPort);
            _ConfigurationReader = new ConfigurationReader(_CommandProcessor, _ModuleConfiguration);
            _ConfigurationWriter = new ConfigurationWriter(_CommandProcessor, _ModuleConfiguration);
            _ServerConfiguration = new LocalServerConfiguration();

            SettingsPage       = new Settings(_SerialPort, _ConfigurationReader, _ConfigurationWriter, _ModuleConfiguration, _ServerConfiguration);
            BasicSetupPage     = new BasicSetup(_CommandProcessor, _ModuleConfiguration);
            WiFiSetupPage      = new WiFiSetup(_CommandProcessor, _ModuleConfiguration);
            TCPIPSetupPage     = new TCPUDPSettings(_CommandProcessor, _ModuleConfiguration);
            DataLoggerPage     = new DataLogging(_ServerConfiguration);
            RemoteTerminalPage = new RemoteTerminal(_ServerConfiguration);

            SettingsListViewItem.IsSelected = true;
        }
Пример #5
0
        public static void BrowseLibrary()
        {
            IO.OutputNewLine(ShowBookTitles());
            IO.OutputNewLine();

            string[] actionsArray = IO.SplitAndSanitizeInput(IO.GetInput());

            while (!actionsArray[0].Equals("leave"))
            {
                // Empty line buffer after getting input
                IO.OutputNewLine();

                switch (actionsArray[0])
                {
                case "read":
                    if (CommandProcessingService.ValidateNoun(actionsArray))
                    {
                        IO.OutputNewLine(ReadBook(actionsArray));
                    }
                    else
                    {
                        IO.OutputNewLine("Try including a title after 'read'.");
                    }
                    break;

                default:
                    IO.OutputNewLine("enter 'leave' to leave");
                    break;
                }

                // Empty line buffer before getting next input
                IO.OutputNewLine();

                actionsArray = IO.SplitAndSanitizeInput(IO.GetInput());
            }
        }
Пример #6
0
        static void Main()
        {
            // Initialize and start the game
            Game.Start();

            // Herein lies the major flow of the game:
            while (Game.GetState())
            {
                // Collect and filter user commands
                string info = IO.PromptAndGetInput();

                // Empty line buffer after getting input
                IO.OutputNewLine();

                // Process user commands
                string[] commands = IO.SplitAndSanitizeInput(info);
                CommandProcessingService.ParseInput(commands);

                // Empty line buffer before getting next input
                IO.OutputNewLine();
            }

            IO.GetInput();
        }
Пример #7
0
 public CommandsController(CommandProcessingService commandProcessingService)
 {
     _commandProcessingService = commandProcessingService;
 }
Пример #8
0
 public WiFiSetup(CommandProcessingService Processor, ModuleConfiguration ModuleConfiguration)
 {
     InitializeComponent();
     _CommandProcessor    = Processor;
     _ModuleConfiguration = ModuleConfiguration;
 }
 public TCPUDPSettings(CommandProcessingService Processor, Model.ModuleConfiguration ModuleConfiguration)
 {
     InitializeComponent();
     _CommandProcessor    = Processor;
     _ModuleConfiguration = ModuleConfiguration;
 }