protected override void Load() { if (Config.JoinMessageEnable) { U.Events.OnPlayerConnected += Events_OnPlayerConnected; } if (Config.LeaveMessageEnable) { U.Events.OnPlayerDisconnected += Events_OnPlayerDisconnected; } if (Config.DeathMessageEnable) { P.OnPlayerDeath += Events_OnPlayerDeath; } if (Config.AnnouncementsEnable && Config.Commands != null) { Command = new List <TextCommand>(); foreach (var item in Config.Commands) { var command = new TextCommand(item.Name, item.Help, item.Text); Command.Add(command); R.Commands.Register(command); } } Instance.Configuration.Save(); Logger.Log($"[{name}] Successfully Loaded!"); }
public override void handleConnectCmd(ProtocolContext ctx, TextCommand cmd) { ctx.device_id = cmd.device_id; ctx.device_name = cmd.device_name; handler.HandleConnectMsg(cmd, ctx); }
// Use this for initialization void Start() { //Testing Score Stuff lotsOfDots = GameObject.Find("Opening"); scoreboard = lotsOfDots.GetComponent <DotMatrix>(); controller = scoreboard.GetController(); //controller.AddCommand(textCommand); TextCommand textCommand = new TextCommand("Beachfront Tech") { HorPosition = TextCommand.HorPositions.Center, Movement = TextCommand.Movements.MoveLeftAndStop }; controller.AddCommand(textCommand); controller.AddCommand(new PauseCommand(5f)); controller.AddCommand(new ClearCommand() { Method = ClearCommand.Methods.MoveRight }); // }
public void Setup() { this.entity = new TextCommand(); this.model = new TextCommandModel(); this.mapper = new TextCommandMapper(); }
protected override void Init() { if (String.IsNullOrEmpty(CommandPrefix)) { CommandPrefix = "!"; } if (TextCommands == null) { TextCommands = new TextCommand[0]; } if (Accounts == null) { Accounts = new TwitchAccount[0]; } if (TwitchUsers == null) { TwitchUsers = new TwitchUser[0]; } if (String.IsNullOrEmpty(SubMessageNew)) { SubMessageNew = @"Thank you for the sub %name%! <3"; } if (String.IsNullOrEmpty(SubMessageResub)) { SubMessageResub = @"Thank you for the %months% sub, %name%! <3"; } if (String.IsNullOrEmpty(CoinName)) { CoinName = @"Coin(s)"; } }
public void AddCommand(TextCommand c) { List <TextCommand> a = TextCommands.ToList(); a.Add(c); TextCommands = a.ToArray(); }
public void StopsExecutionAfterRobotWasLost() { _commandFactoryMock.Setup(x => x.IsSupported(It.IsAny <char>())).Returns(true); var aMock = new Mock <ICommand>(); aMock.Setup(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>())).Returns(Task.FromResult(0)); _commandFactoryMock.Setup(x => x.GetCommand(It.Is <char>(c => c == 'a'))).Returns(aMock.Object); var bMock = new Mock <ICommand>(); bMock.Setup(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>())) .Callback((IGrid grid, IRobot robot) => robot.Status = RobotStatus.LOST) .Returns(Task.FromResult(0)); _commandFactoryMock.Setup(x => x.GetCommand(It.Is <char>(c => c == 'b'))).Returns(bMock.Object); var cMock = new Mock <ICommand>(); cMock.Setup(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>())).Returns(Task.FromResult(0)); _commandFactoryMock.Setup(x => x.GetCommand(It.Is <char>(c => c == 'c'))).Returns(cMock.Object); var command = new TextCommand("abc", _commandFactoryMock.Object); command.ExecuteAsync(_gridMock.Object, _robot).Wait(); aMock.Verify(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>()), Times.Once); bMock.Verify(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>()), Times.Once); cMock.Verify(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>()), Times.Never); }
public void ExecutesAllCommandsOneByOne() { string actualString = ""; _commandFactoryMock.Setup(x => x.IsSupported(It.IsAny <char>())).Returns(true); var aMock = new Mock <ICommand>(); aMock.Setup(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>())).Callback(() => actualString += "a"); _commandFactoryMock.Setup(x => x.GetCommand(It.Is <char>(c => c == 'a'))).Returns(aMock.Object); var bMock = new Mock <ICommand>(); bMock.Setup(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>())).Callback(() => actualString += "b"); _commandFactoryMock.Setup(x => x.GetCommand(It.Is <char>(c => c == 'b'))).Returns(bMock.Object); var cMock = new Mock <ICommand>(); cMock.Setup(x => x.ExecuteAsync(It.IsAny <IGrid>(), It.IsAny <IRobot>())).Callback(() => actualString += "c"); _commandFactoryMock.Setup(x => x.GetCommand(It.Is <char>(c => c == 'c'))).Returns(cMock.Object); var command = new TextCommand("abc", _commandFactoryMock.Object); command.ExecuteAsync(_gridMock.Object, _robot).Wait(); Assert.AreEqual("abc", actualString); }
private static IEnumerable <TextCommand> CreateReloadCommands() { var cmd = new TextCommand( (string logLine, out Match match) => { match = null; if (!logLine.ContainsIgnoreCase(TimelineCommand)) { return(false); } match = ReloadCommandRegex.Match(logLine); return(match.Success); }, async(string logLine, Match match) => { if (match == null || !match.Success) { return; } if (TimelineController.CurrentController != null) { await TimelineController.CurrentController.Model.ExecuteReloadCommandAsync(); } }); return(new[] { cmd }); }
private static ICommand ConstructCommand(string instructions) { ICommand command = new TextCommand(instructions, CommandFactory); command = new ReportingCommandDecorator(command, Reporter); return(command); }
public bool IsRowUpdated() { var command = new TextCommand(string.Format(@" select 1 from orderline where ordernumber = {0} and linenumber= {1} and supplementarytext5 like '%{2}%'", OrderNumber, LineNumber, "LETTER")); var caller = new DbCaller(command); caller.DoWork(); return(!(caller.GetResult() is null)); }
protected override void CommandHandler_OnException(TextCommand command, TContext AContext, Exception exception) { base.CommandHandler_OnException(command, AContext, exception); if (mAppendExceptionToReply) { command.Response.Add(exception.ToString()); } }
/// <summary> /// Valid packet processing. /// </summary> /// <param name="packet">Packet for validation.</param> public void HandlePacket(Packet packet) { if (packet == null) { throw new Exception("packet can`t be null"); } // The choice of actions depending on the type of command. switch (packet.commandCharacter) { case "T": { TextCommand textCommand = new TextCommand(packet.parameters); ColourPrinter.Print("\nACK", ConsoleColor.Green); textCommand.Action(); break; }; case "S": { List <int> paramList = new List <int>(); // Convert the parameters to a list of integers. foreach (string str in commandValidator.GetParamsList(packet.parameters)) { if (int.TryParse(str.Trim(), out int result)) { paramList.Add(result); } else { throw new Exception("Parameter can`t be parsed."); } } // In this type of command, two required parameters are required - frequency and duration. if (paramList.Count != 2) { throw new Exception("Parameter list have wrong number of items."); } // The zero parameter is frequency. The first is duration. SoundCommand soundCommand = new SoundCommand(paramList[0], paramList[1]); ColourPrinter.Print("\nACK", ConsoleColor.Green); soundCommand.Action(); break; }; default: { throw new Exception("Undefined packet command character."); }; } }
/// <summary> /// Executes this action. /// </summary> /// <param name="model">The model.</param> /// <param name="context">The context.</param> public override void Execute(RootModel model, ActionExecutionContext context) { Assert.ArgumentNotNull(model, "model"); Assert.ArgumentNotNull(context, "context"); var cmd = new TextCommand("#status " + CommandText); model.PushCommandToConveyor(cmd); }
private void OnResponseUpdate(object sender, PropertyChangedEventArgs e) { TextCommandModel model = (TextCommandModel)sender; TextCommand entity = new TextCommand(); this.mapper.MapToEntity(model, entity); this.repository.AddOrUpdate(entity); }
public ReaderTextOutput(byte readerNumber, TextCommand textCommand, byte temporaryTextTime, byte row, byte column, string text) { ReaderNumber = readerNumber; TextCommand = textCommand; TemporaryTextTime = temporaryTextTime; Row = row; Column = column; Text = text; }
public void AddOrUpdateShouldAddNewElement(string id) { TextCommand model = new TextCommand(); this.repository.AddOrUpdate(model); this.entities.Verify(e => e.Insert(model)); this.entities.Verify(e => e.Update(model), Times.Never); }
protected override void Generate(TextCommand cmd) { var escapedText = cmd.Text.Text.Escape(); this.TextRenderer.Write("_Template.Write(() => \"", cmd.Text.Position); this.TextRenderer.Write(escapedText, cmd.Text.Position, EntryFeatures.ColumnInterpolation); this.TextRenderer.Write($"\", {this.SourceExpression(cmd.Text.Position)}, {this.FeatureExpression(EntryFeatures.ColumnInterpolation)});", cmd.End.Position); this.TextRenderer.WriteLine(cmd.End.Position); }
/*******************************************************************************/ private async Task ExecuteQuery(string text) { using (Database db = Database.Create(_connectionString, false)) { using (TextCommand sp = new TextCommand(db, text)) { await db.DoTaskAsync(sp); } } }
/*******************************************************************************/ private async Task <IDictionary <string, object> > ExecuteQueryResult(Query query) { using (Database db = Database.Create(_connectionString, false)) { using (TextCommand sp = new TextCommand(db, query.ToString())) { return(await db.ExecuteSingleRecordDictionaryAsync(sp)); } } }
public async Task Handle(Command command) { var response = new TextCommand { CommandType = CommandType.TextResponse, Text = (command as TextCommand)?.Text }; await _transportHandler.Send(response.Serialize()); }
public void GetShouldReturnElement(string id) { TextCommand entity = new TextCommand { Id = id }; this.entities.Setup(e => e.FindOne(It.IsAny <Expression <Func <TextCommand, bool> > >())).Returns(entity); TextCommand shoutout = this.repository.Get(s => s.Id == id); Assert.AreEqual(entity, shoutout); }
public void ClientOnMessageReceived(object sender, MessageEventArgs e) { // Determine if plugin first. if (e.Message.Message.StartsWith(Settings.Default.CommandPrefix)) { var command = new TextCommand(e.Message); RaiseCommandReceived(sender, command, e); return; } _messageReceivedEventSource.Raise(sender, e); }
public void Setup() { this.repository = new Mock <IRepository <TextCommand> >(); this.wildcardReplacer = new Mock <IWildcardReplacer>(); this.chatCommand = new Mock <IChatCommand>(); this.chatCommand.Setup(c => c.ChatMessage).Returns(new Mock <IChatMessage>().Object); this.StubWildcardReplacer(); this.textCommand = new TextCommand(); this.replyLoader = new TextCommandReplyLoader(this.repository.Object, this.wildcardReplacer.Object); }
public Boolean UpdateCommand(TextCommand tc) { foreach (TextCommand t in TextCommands) { if (t.Command == tc.Command) { t.Update(tc.Output, tc.Permission, tc.Timeout); return(true); } } return(false); }
protected virtual object LoadOptions(Type optionsType, TextCommand command) { bool errorOccured; var serializer = new OptionsSerializer(this, optionsType); var retval = serializer.Deserialize(command.Parameters, out errorOccured); if (errorOccured) { throw new ProcessNextCommandException(); } return(retval); }
public void AddOrUpdateShouldUpdateUseCount(int count) { TextCommand entity = new TextCommand(); TextCommand model = new TextCommand { UseCount = count }; this.entities.Setup(e => e.FindOne(It.IsAny <Expression <Func <TextCommand, bool> > >())).Returns(entity); this.repository.AddOrUpdate(model); Assert.AreEqual(count, entity.UseCount); }
private void setRandomNextStop() { // Create next text command which is displaying next stop TextCommand newNextStopMessage = new TextCommand("Next stop: " + getRandomNextStop()) { Movement = TextCommand.Movements.MoveLeftAndPass, Repeat = true }; // Replace old next stop text in queue with new one controller.ReplaceCommand(nextStopMessage, newNextStopMessage); nextStopMessage = newNextStopMessage; }
public void HandleSHouldSendNothingIfNoReplyFound() { TextCommand command = new TextCommand(); this.repository.Setup(r => r.GetAll()).Returns(new[] { command }); string reply; this.replyLoader.Setup(l => l.TryGetReply(command, this.chatCommand.Object, out reply)).Returns(false); this.handler.Handle(this.twitchClient.Object, this.chatCommand.Object); this.twitchClient.Verify(c => c.SendMessage(It.IsAny <string>(), It.IsAny <string>(), false), Times.Never); }
private bool WriteCommand(TextCommand cmd) { if (cmd == null) { return(false); } return(WriteCommand(cmd as NextlineWithOffset) || WriteCommand(cmd as NextLine) || WriteCommand(cmd as PrintString) || WriteCommand(cmd as SetTextMatrix) || WriteCommand(cmd as SetFontCommand) /* || WriteCommand(cmd as SetGray) */); }
private bool WriteCommand(TextCommand cmd) { if (cmd == null) return false; return WriteCommand(cmd as NextlineWithOffset) || WriteCommand(cmd as NextLine) || WriteCommand(cmd as PrintString) || WriteCommand(cmd as SetTextMatrix) || WriteCommand(cmd as SetFontCommand) /* || WriteCommand(cmd as SetGray) */ ; }