本文整理汇总了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;
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 ) );
}
示例9: SendCommand
public void SendCommand( ChatCommand command )
{
SendCommand( command, null, null, null );
}
示例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;
}
示例11: CommandPermissionEvent
public CommandPermissionEvent(Player player, string[] command, ChatCommand chatCmd)
: base(player, command)
{
ChatCommand = chatCmd;
}
示例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);
}
示例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");
}
示例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);
}
}
示例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 );
}
}