コード例 #1
0
        /// <summary>
        /// Implementation of <see cref="OnChatMessage"/> that recieves messages from all channels of all connected <see cref="ChatProviders"/>
        /// </summary>
        /// <param name="ChatProvider">The <see cref="IChatProvider"/> that heard the <paramref name="message"/></param>
        /// <param name="speaker">The user who wrote the <paramref name="message"/></param>
        /// <param name="channel">The channel the <paramref name="message"/> is from</param>
        /// <param name="message">The recieved message</param>
        /// <param name="isAdmin"><see langword="true"/> if <paramref name="speaker"/> is considered a chat admin, <see langword="false"/> otherwise</param>
        /// <param name="isAdminChannel"><see langword="true"/> if <paramref name="channel"/> is an admin channel, <see langword="false"/> otherwise</param>
        private void ChatProvider_OnChatMessage(IChatProvider ChatProvider, string speaker, string channel, string message, bool isAdmin, bool isAdminChannel)
        {
            var splits = message.Trim().Split(' ');

            if (splits.Length == 1 && splits[0] == "")
            {
                ChatProvider.SendMessageDirect("Hi!", channel);
                return;
            }

            var asList = new List <string>(splits);

            Command.OutputProcVar.Value   = (m) => ChatProvider.SendMessageDirect(m, channel);
            ChatCommand.CommandInfo.Value = new CommandInfo()
            {
                IsAdmin        = isAdmin,
                IsAdminChannel = isAdminChannel,
                Speaker        = speaker,
                Server         = this,
            };
            WriteInfo(String.Format("Chat Command from {0} ({2}): {1}", speaker, String.Join(" ", asList), channel), EventID.ChatCommand);
            if (ServerChatCommands == null)
            {
                LoadServerChatCommands();
            }
            new RootChatCommand(ServerChatCommands).DoRun(asList);
        }