当前位置: 首页>>代码示例>>C#>>正文


C# ChatCommand类代码示例

本文整理汇总了C#中ChatCommand的典型用法代码示例。如果您正苦于以下问题:C# ChatCommand类的具体用法?C# ChatCommand怎么用?C# ChatCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChatCommand类属于命名空间,在下文中一共展示了ChatCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddChatCommand

        public void AddChatCommand(string name, Plugin plugin, string callback_name)
        {
            var command_name = name.ToLowerInvariant();

            ChatCommand cmd;
            if (chatCommands.TryGetValue(command_name, out cmd))
            {
                var previous_plugin_name = cmd.Plugin?.Name ?? "an unknown plugin";
                var new_plugin_name = plugin?.Name ?? "An unknown plugin";
                var msg = $"{new_plugin_name} has replaced the '{command_name}' chat command previously registered by {previous_plugin_name}";
                Interface.Oxide.LogWarning(msg);
            }

            cmd = new ChatCommand(command_name, plugin, callback_name);

            // Add the new command to collections
            chatCommands[command_name] = cmd;

            var commandAttribute = new CommandAttribute("/" + command_name, string.Empty);
            var action = (Action<CommandInfo>)Delegate.CreateDelegate(typeof(Action<CommandInfo>), this, GetType().GetMethod("HandleCommand", BindingFlags.NonPublic | BindingFlags.Instance));
            commandAttribute.Method = action;
            if (CommandManager.RegisteredCommands.ContainsKey(command_name))
            {
                var new_plugin_name = plugin?.Name ?? "An unknown plugin";
                var msg = $"{new_plugin_name} has replaced the '{command_name}' chat command";
                Interface.Oxide.LogWarning(msg);
            }
            CommandManager.RegisteredCommands[command_name] = commandAttribute;

            // Hook the unload event
            if (plugin) plugin.OnRemovedFromManager += plugin_OnRemovedFromManager;
        }
开发者ID:906507516,项目名称:Oxide,代码行数:32,代码来源:Command.cs

示例2: ProcessChange

        /// <summary>
        ///     Processes the input text and returns the processed value.
        /// </summary>
        /// <returns>The processed output</returns>
        protected override string ProcessChange()
        {
            var result = new AlfredCommandResult();

            var recipient = ChatEngine.Owner as IAlfredCommandRecipient;

            // Check to make sure we have a recipient to talk to
            if (recipient == null)
            {
                Log(Resources.AlfredTagHandlerProcessChangeNoRecipient, LogLevel.Warning);

                return result.Output.NonNull();
            }

            // Build a command
            var name = GetAttribute("command");
            var subsystem = GetAttribute("subsystem");
            var data = GetAttribute("data");

            var command = new ChatCommand(subsystem, name, data);

            // Send the command on to the owner. This may modify result or carry out other actions.
            recipient.ProcessAlfredCommand(command, result);

            // Get the output value from the result in case it was set externally
            return result.Output.NonNull();
        }
开发者ID:IntegerMan,项目名称:Alfred,代码行数:31,代码来源:AlfredTagHandler.cs

示例3: button_Click

        private void button_Click(object sender, RoutedEventArgs e)
        {
            if (commandBox.Text == "" || nameBox.Text == "")
            {
                MessageBox.Show("You must include a name and a command.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
            }
            else
            {
                CC = new ChatCommand()
                {
                    Name = "",
                    Command = "",
                    TriggerNumbers = new TriggerNumbers(),
                    TriggerLists = new TriggerLists()
                };

                CC.Command = commandBox.Text;
                CC.Name = nameBox.Text;
                List<SteamID> ignores = new List<SteamID>();
                List<SteamID> rooms = new List<SteamID>();
                List<SteamID> users = new List<SteamID>();
                if (delayBox.Text == "") CC.TriggerNumbers.Delay = null;
                else CC.TriggerNumbers.Delay = Convert.ToInt32(delayBox.Text);

                if (probBox.Text == "") CC.TriggerNumbers.Probability = null;
                else CC.TriggerNumbers.Probability = (float)Convert.ToDouble(probBox.Text);

                if (timeoutBox.Text == "") CC.TriggerNumbers.Timeout = null;
                else CC.TriggerNumbers.Timeout = Convert.ToInt32(timeoutBox.Text);

                if (ignoresBox.Text.Split(',').Length > 0 && ignoresBox.Text != "")
                {
                    foreach (string ignore in ignoresBox.Text.Split(','))
                    {
                        ignores.Add(new SteamID(Convert.ToUInt64(ignore)));
                    }
                }
                if (roomsBox.Text.Split(',').Length > 0 && roomsBox.Text != "")
                {
                    foreach (string room in roomsBox.Text.Split(','))
                    {
                        rooms.Add(new SteamID(Convert.ToUInt64(room)));
                    }
                }
                if (usersBox.Text.Split(',').Length > 0 && usersBox.Text != "")
                {
                    foreach (string user in usersBox.Text.Split(','))
                    {
                        users.Add(new SteamID(Convert.ToUInt64(user)));
                    }
                }

                CC.TriggerLists.Ignore = ignores;
                CC.TriggerLists.Rooms = rooms;
                CC.TriggerLists.User = users;
                DialogResult = true;
                Close();
            }
        }
开发者ID:Steam-Chat-Bot,项目名称:SteamChatBot,代码行数:59,代码来源:ChatCommandWindow.xaml.cs

示例4: CanAccess

        /// <summary>
        /// Checks if a player can use a certain command based on the permissions system.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="command"></param>
        /// <returns></returns>
        public static bool CanAccess(this IMyPlayer player, ChatCommand command)
        {
            if (player.IsAdmin())
                return true;
            if (Storage.Data.Perms.Groups.Count == 0)
                return true;
            if (Storage.Data.Perms.Groups.Find(g => g.Members.Contains(player.PlayerID) && g.Commands.Contains(command.Name)) != null)
                return true;

            return false;
        }
开发者ID:Jimmacle,项目名称:JimsCommands,代码行数:17,代码来源:Extensions.cs

示例5: UserStatementResponse

 /// <summary>Initializes a new instance of the <see cref="UserStatementResponse" /> class.</summary>
 /// <param name="userInput">The user input.</param>
 /// <param name="responseText">The response text.</param>
 /// <param name="template">The template.</param>
 /// <param name="command">The Command.</param>
 /// <param name="resultData">Information describing the result.</param>
 public UserStatementResponse(
     [CanBeNull] string userInput,
     [CanBeNull] string responseText,
     [CanBeNull] string template,
     ChatCommand command,
     [CanBeNull] object resultData)
 {
     UserInput = userInput ?? string.Empty;
     ResponseText = responseText ?? string.Empty;
     Template = template;
     Command = command;
     ResultData = resultData;
 }
开发者ID:IntegerMan,项目名称:Alfred,代码行数:19,代码来源:UserStatementResponse.cs

示例6: AddChatCommand

        public void AddChatCommand(string name, Plugin plugin, string callback_name)
        {
            var command_name = name.ToLowerInvariant();
            ChatCommand cmd;
            if (chatCommands.TryGetValue(command_name, out cmd))
            {
                var previous_plugin_name = cmd.Plugin?.Name ?? "an unknown plugin";
                var new_plugin_name = plugin?.Name ?? "An unknown plugin";
                var msg = $"{new_plugin_name} has replaced the '{command_name}' chat command previously registered by {previous_plugin_name}";
                Interface.Oxide.LogWarning(msg);
            }
            cmd = new ChatCommand(command_name, plugin, callback_name);

            // Add the new command to collections
            chatCommands[command_name] = cmd;

            // Hook the unload event
            if (plugin) plugin.OnRemovedFromManager += plugin_OnRemovedFromManager;
        }
开发者ID:RuanPitout88,项目名称:Oxide,代码行数:19,代码来源:Command.cs

示例7: ProcessAlfredCommand

        /// <summary>
        ///     Processes an Alfred Command. If the command is handled, result should be modified accordingly
        ///     and the method should return true. Returning false will not stop the message from being
        ///     propagated.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="result">The result. If the command was handled, this should be updated.</param>
        /// <returns><c>True</c> if the command was handled; otherwise false.</returns>
        public bool ProcessAlfredCommand(ChatCommand command, AlfredCommandResult result)
        {
            var alfred = Alfred;
            if (alfred == null)
            {
                return false;
            }

            // Extract our target for loop readability
            var target = command.Subsystem;

            // Commands are very, very important and need to be logged.
            alfred.Console?.Log(Resources.AlfredCommandRouterProcessAlfredCommandLogHeader,
                                string.Format(CultureInfo.CurrentCulture,
                                              Resources.AlfredCommandRouterProcessAlfredCommandLogMessage,
                                              command.Name,
                                              target,
                                              command.Data),
                                LogLevel.Info);

            // Send the command to each subsystem. These will in turn send it on to their pages and modules.
            foreach (var subsystem in alfred.Subsystems)
            {
                // If the command isn't for the subsystem, move on.
                if (target.HasText() && !target.Matches(subsystem.Id))
                {
                    continue;
                }

                // Send the command to the subsystem for routing. If it's handled, the subsystem will return true.
                if (subsystem.ProcessAlfredCommand(command, result))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:IntegerMan,项目名称:Alfred,代码行数:46,代码来源:AlfredCommandRouter.cs

示例8: SendCommandTo

		public static void SendCommandTo( Mobile to, ChatCommand type, string param1, string param2 )
		{
			if ( to != null )
				to.Send( new ChatMessagePacket( null, (int)type + 20, param1, param2 ) );
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:5,代码来源:Chat.cs

示例9: SendCommand

		public void SendCommand( ChatCommand command )
		{
			SendCommand( command, null, null, null );
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:4,代码来源:Channel.cs

示例10: ProcessAlfredCommand

        /// <summary>
        ///     Processes an Alfred Command. If the <paramref name="command" /> is handled,
        ///     <paramref name="result" /> should be modified accordingly and the method should return true.
        ///     Returning false will not stop the message from being propagated.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="result">The result. If the command was handled, this should be updated.</param>
        /// <returns><c>True</c> if the command was handled; otherwise false.</returns>
        public virtual bool ProcessAlfredCommand(
            ChatCommand command,
            [CanBeNull] AlfredCommandResult result)
        {
            /* If there's no result, there's no way any feedback could get back.
            This is just here to protect against bad input */

            if (result == null) { return false; }

            // Only route messages to sub-components if they don't have a destination
            if (command.Subsystem.IsEmpty() || command.Subsystem.Matches(Id))
            {
                foreach (var page in Pages)
                {
                    if (page.ProcessAlfredCommand(command, result)) { return true; }
                }
            }

            return false;
        }
开发者ID:IntegerMan,项目名称:Alfred,代码行数:28,代码来源:AlfredSubSystem.cs

示例11: CommandPermissionEvent

 public CommandPermissionEvent(Player player, string[] command, ChatCommand chatCmd)
     : base(player, command)
 {
     ChatCommand = chatCmd;
 }
开发者ID:Notulp,项目名称:Pluton.Rust,代码行数:5,代码来源:CommandPermissionEvent.cs

示例12: RegisterChatCommand

        public void RegisterChatCommand(ChatCommand command)
        {
            //Check if the given command already is registered
            foreach (ChatCommand chatCommand in m_chatCommands)
            {
                if (chatCommand.command.ToLower().Equals(command.command.ToLower()))
                    return;
            }

            m_chatCommands.Add(command);
        }
开发者ID:noxer,项目名称:SE-Community-Mod-API,代码行数:11,代码来源:ChatManager.cs

示例13: ChatManager

        protected ChatManager()
        {
            m_instance = this;

            m_chatMessages = new List<string>();
            m_chatHandlerSetup = false;
            m_chatEvents = new List<ChatEvent>();
            m_chatCommands = new List<ChatCommand>();

            ChatCommand deleteCommand = new ChatCommand();
            deleteCommand.command = "delete";
            deleteCommand.callback = Command_Delete;
            deleteCommand.requiresAdmin = true;

            ChatCommand tpCommand = new ChatCommand();
            tpCommand.command = "tp";
            tpCommand.callback = Command_Teleport;
            tpCommand.requiresAdmin = true;

            ChatCommand stopCommand = new ChatCommand();
            stopCommand.command = "stop";
            stopCommand.callback = Command_Stop;
            stopCommand.requiresAdmin = true;

            ChatCommand getIdCommand = new ChatCommand();
            getIdCommand.command = "getid";
            getIdCommand.callback = Command_GetId;
            getIdCommand.requiresAdmin = true;

            ChatCommand saveCommand = new ChatCommand();
            saveCommand.command = "save";
            saveCommand.callback = Command_Save;
            saveCommand.requiresAdmin = true;

            ChatCommand ownerCommand = new ChatCommand();
            ownerCommand.command = "owner";
            ownerCommand.callback = Command_Owner;
            ownerCommand.requiresAdmin = true;

            ChatCommand exportCommand = new ChatCommand();
            exportCommand.command = "export";
            exportCommand.callback = Command_Export;
            exportCommand.requiresAdmin = true;

            ChatCommand importCommand = new ChatCommand();
            importCommand.command = "import";
            importCommand.callback = Command_Import;
            importCommand.requiresAdmin = true;

            ChatCommand spawnCommand = new ChatCommand();
            spawnCommand.command = "spawn";
            spawnCommand.callback = Command_Spawn;
            spawnCommand.requiresAdmin = true;

            ChatCommand clearCommand = new ChatCommand();
            clearCommand.command = "clear";
            clearCommand.callback = Command_Clear;
            clearCommand.requiresAdmin = true;

            ChatCommand listCommand = new ChatCommand();
            listCommand.command = "list";
            listCommand.callback = Command_List;
            listCommand.requiresAdmin = true;

            ChatCommand offCommand = new ChatCommand();
            offCommand.command = "off";
            offCommand.callback = Command_Off;
            offCommand.requiresAdmin = true;

            RegisterChatCommand(deleteCommand);
            RegisterChatCommand(tpCommand);
            RegisterChatCommand(stopCommand);
            RegisterChatCommand(getIdCommand);
            RegisterChatCommand(saveCommand);
            RegisterChatCommand(ownerCommand);
            RegisterChatCommand(exportCommand);
            RegisterChatCommand(importCommand);
            RegisterChatCommand(spawnCommand);
            RegisterChatCommand(clearCommand);
            RegisterChatCommand(listCommand);
            RegisterChatCommand(offCommand);

            SetupWCFService();

            Console.WriteLine("Finished loading ChatManager");
        }
开发者ID:noxer,项目名称:SE-Community-Mod-API,代码行数:86,代码来源:ChatManager.cs

示例14: RegisterChatCommand

 public void RegisterChatCommand(string command, Action<string> func, string description)
 {
     ChatCommand cmd = new ChatCommand(command, func, description);
     if (!registeredChatCommands.ContainsKey(command))
     {
         registeredChatCommands.Add(command, cmd);
     }
 }
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:8,代码来源:ChatWorker.cs

示例15: SendCommand

        public void SendCommand( ChatCommand command, ChatUser initiator, string param1 = null, string param2 = null )
        {
            foreach ( var user in m_Users.ToArray() )
            {
                if ( user == initiator )
                    continue;

                if ( user.CheckOnline() )
                    ChatSystem.SendCommandTo( user.Mobile, command, param1, param2 );
            }
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:11,代码来源:Channel.cs


注:本文中的ChatCommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。