示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            // Hook main window up to messenger
            ClientMessage.SetTarget(ChannelTextBlock);

            // Register slash commands
            SlashCommandRegistry.RegisterHandler("connect", new Commands.Slash.Connect());
            SlashCommandRegistry.RegisterHandler("disconnect", new Commands.Slash.Disconnect());
            SlashCommandRegistry.RegisterHandler("raw", new Commands.Slash.Raw());
            SlashCommandRegistry.RegisterHandler("chan", new Commands.Slash.SetChannel());
            SlashCommandRegistry.RegisterHandler("join", new Commands.Slash.Join());

            // Register server requests
            ServerRequestRegistry.RegisterHandler("NOTICE", new Commands.ServerRequest.Notice());
            ServerRequestRegistry.RegisterHandler("JOIN", new Commands.ServerRequest.Join());
            ServerRequestRegistry.RegisterHandler("PRIVMSG", new Commands.ServerRequest.PrivMsg());
        }
示例#2
0
        public static void Parse(MainWindow window, string value)
        {
            value = value.Trim();
            string command = value.Substring(1);
            string args    = null;

            // Check if command contains arguments
            if (value.IndexOf(' ') > -1)
            {
                command = value.Substring(1, value.IndexOf(' ') - 1);
                args    = value.Substring(value.IndexOf(' ') + 1);
            }

            // Check if command exists
            ISlashCommand cmd = SlashCommandRegistry.GetHandler(command);

            if (cmd == null)
            {
                ClientMessage.Info($"Unknown command '{command}'");
                return;
            }

            cmd.Run(args);
        }