public CommandReceivedEventArgs(ITextCommand command, IServer server, IChannel channel, IUser user) { Command = command; Server = server; Channel = channel; User = user; }
/// <summary> /// Parses a received message /// </summary> /// <param name="message">String received</param> protected override void Parse(ITextMessage message) { if (message is ITextCommand) { ITextCommand cmd = (ITextCommand)message; OnCommandReceived(new Command(this, cmd.Command, cmd.Parameters, cmd.Id)); } else if (message is ITextResponse) { ITextResponse rsp = (ITextResponse)message; OnResponseReceived(new Response(this, rsp.Command, rsp.Parameters, rsp.Success, rsp.Id)); } }
void ExpandSegments() { commandsExpanded.Clear(); foreach (ExpansionSegment expansionSegment in expansionSegments) { ITextCommand expandedCommand = expansionSegment.ExpandCommand(); if (expandedCommand != null) { commandsExpanded.Add(expandedCommand); } expansionSegment.ExpandText(); } }
/// <summary> /// Sends a command to the module /// </summary> /// <param name="command">Response to send</param> /// <returns>true if the command has been sent, false otherwise</returns> public override bool Send(ITextCommand command) { // Check if this module is the destination module for the command if (this != command.Destination) { throw new Exception("Command marked to be sent through other module"); } // Check if module is not busy nor running and command is not a priority command if (!running || (Busy && !command.Prototype.HasPriority)) { return(false); } // Send the command return(true); }
public static ITextCommand Execute(string command, TextArea textArea, TextDocument document) { if (string.IsNullOrWhiteSpace(command)) { return(null); } if (!TemplateEngine.TextCommands.ContainsKey(command)) { return(null); } ITextCommand textCommand = (ITextCommand)Activator.CreateInstance(TemplateEngine.TextCommands[command]); if (textCommand == null) { return(null); } textCommand.Execute(textArea, document); return(textCommand); }
public void RaiseCommandReceived(object sender, ITextCommand command, MessageEventArgs e) { // First check all plugins and see if any command comes close. List <string> potentialCommands = (from plugin in _kernel.GetAll <IPlugin>().Where(plugin => plugin.RegisteredTextCommands != null) from cmd in plugin.RegisteredTextCommands where cmd.StartsWith(command.Command) select cmd).ToList(); if (!potentialCommands.Contains(command.Command)) { if (potentialCommands.Count > 1) { e.ReplyTarget.Send("Did you mean: " + string.Join(", ", potentialCommands)); return; } else if (potentialCommands.Count == 1) { ((TextCommand)command).Command = potentialCommands.First(); // force override i don't give a heck } else { e.ReplyTarget.Send("the f**k is that"); return; } } _commandEventSource.RaiseAsync(sender, new CommandReceivedEventArgs(command, e.Server, e.Channel, e.User), delegate(object o) { var pluginInstance = o as IPlugin; if (pluginInstance?.RegisteredTextCommands?.Contains(command.Command) == true) { // Run Sieve. var sieveEvent = new CommandSieveEventArgs(pluginInstance, command); _commandSieveEventSource.Raise(this, sieveEvent); return(sieveEvent.Pass); } return(false); }); }
private void blackboard_ResponseRedirected(ITextCommand command, ITextResponse response, bool sendResponseSuccess) { try { if (this.InvokeRequired) { if (!this.IsHandleCreated || this.Disposing || this.IsDisposed) return; this.BeginInvoke(dlgBlackboardResponseRedirected, command, response, sendResponseSuccess); return; } if (command == null) return; //if ((command.Response == null) && (response != null)) //command.Response = null; dispatchedCommands.Add(command); AddRedirectionListItem(command, response); } catch { } }
private TextMessageService(ITextCommand command, Message message) { _command = command; _message = message; }
private void module_CommandReceived(IModuleClient sender, ITextCommand c) { Command cmd = c as Command; if (c == null) return; // A command has been received so it is stored commandsPending.Produce(cmd); if (sender == virtualModule) Log.WriteLine(6, "<- [" + c.Source.Name + "]: " + c.ToString()); else Log.WriteLine(5, "<- [" + c.Source.Name + "]: " + c.ToString()); }
private int rhComparisonResponse(ITextCommand c1, ITextCommand c2) { return c1.Response.ToString().CompareTo(c2.Response.ToString()); }
private int rhComparisonCommand(ITextCommand c1, ITextCommand c2) { return c1.ToString().CompareTo(c2.ToString()); }
private void ModuleClient_CommandReceived(IModuleClient sender, ITextCommand c) { base.ProduceData(c); }
private int rhComparisonSource(ITextCommand c1, ITextCommand c2) { return c1.Source.CompareTo(c2.Source); }
/// <summary> /// Sends a command to the module /// </summary> /// <param name="command">Response to send</param> /// <returns>true if the command has been sent, false otherwise</returns> public override bool Send(ITextCommand command) { // Check if this module is the destination module for the command if (this != command.Destination) throw new Exception("Command marked to be sent through other module"); // Check if module is not busy nor running and command is not a priority command if (!running || (Busy && !command.Prototype.HasPriority)) return false; // Send the command return true; }
private ListViewItem CreateRedirectionListItem(ITextCommand command, ITextResponse response) { ListViewItem item; int index; if (command == null) { item = new ListViewItem("#Corrupt#"); item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Unknown#"); item.BackColor = Color.Red; return item; } if ((response == null) && (command.Response != null)) response = command.Response; item = new ListViewItem(command.ToString()); index = lvwRedirectionHistory.Items.Count; item.Tag = command; if (response != null) item.SubItems.Add(response.ToString()); else item.SubItems.Add("#Corrupt#"); item.SubItems.Add(command.Source.Name); item.SubItems.Add(command.Destination.Name); item.SubItems.Add(command.SentTime.ToString()); if (response != null) { item.SubItems.Add(response.ArrivalTime.ToString()); item.SubItems.Add(response.FailReason.ToString()); item.SubItems.Add((response.SentStatus == SentStatus.SentSuccessfull ? "Yes" : "No")); if (response.FailReason == ResponseFailReason.ExecutedButNotSucceded) { if (index % 2 == 0) item.BackColor = Color.Lime; else item.BackColor = Color.LightGreen; } else if (response.SentStatus != SentStatus.SentSuccessfull) { if (index % 2 == 0) item.BackColor = Color.LightYellow; else item.BackColor = Color.LightGoldenrodYellow; } else if (response.FailReason != ResponseFailReason.None) { if (index % 2 == 0) item.BackColor = Color.LightPink; else item.BackColor = Color.LightSalmon; } else { if (index % 2 == 0) item.BackColor = Color.White; else item.BackColor = Color.WhiteSmoke; } } else { item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Corrupt#"); item.SubItems.Add("#Unknown#"); } return item; }
private int rhComparisonDestination(ITextCommand c1, ITextCommand c2) { return c1.Destination.CompareTo(c2.Destination); }
private int rhComparisonSentStatus(ITextCommand c1, ITextCommand c2) { return c1.Response.SentStatus.CompareTo(c2.Response.SentStatus); }
private int rhComparisonInfo(ITextCommand c1, ITextCommand c2) { return c1.Response.FailReason.CompareTo(c2.Response.FailReason); }
private int rhComparisonArrival(ITextCommand c1, ITextCommand c2) { return c1.Response.ArrivalTime.CompareTo(c2.Response.ArrivalTime); }
private int rhComparisonSentTime(ITextCommand c1, ITextCommand c2) { return c1.SentTime.CompareTo(c2.SentTime); }
public CommandSieveEventArgs(IPlugin target, ITextCommand command) { Pass = true; TargetPlugin = target; Command = command; }
/// <summary> /// Sends a command to the module /// </summary> /// <param name="command">Response to send</param> /// <returns>true if the command has been sent, false otherwise</returns> public virtual bool Send(ITextCommand command) { if(command is Command) return Send((Command) command); return false; }
public void Add(ITextCommand command) { _commands.Add(command.Text.ToLower(), command); }
private void AddRedirectionListItem(ITextCommand command, ITextResponse response) { if (this.InvokeRequired) { if (!IsHandleCreated || IsDisposed || Disposing) return; this.BeginInvoke(dlgAddRedirectionListItem, command, response); return; } lvwRedirectionHistory.Items.Add(CreateRedirectionListItem(command, response)); lvwRedirectionHistory.Refresh(); }