public void EmmitBotCommand(BotCommand command) { for (int i = 0; i < FBotList.Count; ++i) { FBotList[i].EmmitBotCommand(command); } }
private static RfqComment ParseComment(BotCommand command) { return(new RfqComment( command.Get("requestId"), command["requestParty"], command["counterParty"], null, command["comment"])); }
public void Deconstruct( out JokeType type, out BotCommand command, out string lang) { type = JokeType; command = BotCommand; lang = Language; }
private Command( JokeType type, BotCommand command, string lang) { JokeType = type; BotCommand = command; Language = lang; }
public void EmmitBotCommand(BotCommand command) { lock (FLock) { if(FLua == null) return; EmmitBotEvent(new BotEvent_Command(command)); } }
private void CompleteCommand() { BotCommand _tempCommand = commandQueue.Dequeue(); if (_tempCommand.appendWhenComplete) { commandQueue.Enqueue(_tempCommand); } BeginCommand(commandQueue.Peek()); }
private async Task Send(BotCommand command, string payload) { if (ControlPort > 0 && ControlPort <= ushort.MaxValue) { var pl = Encoding.UTF8.GetBytes(payload); var data = new[] { (byte)command }; data = data.Concat(pl).ToArray(); await _controlClient.SendAsync(data, data.Length, new IPEndPoint(IPAddress.Loopback, ControlPort)); } }
public PlayCommand(string audioType, string cmdPath) { this.audioType = audioType; var builder = new CommandBuildInfo( this, Method, new CommandAttribute(cmdPath)); Command = new BotCommand(builder); }
public PlayListCommand(IPlaylistResolver resolver, string cmdPath) { this.resolver = resolver; var builder = new CommandBuildInfo( this, Method, new CommandAttribute(cmdPath)); Command = new BotCommand(builder); }
public JsonResult RemovePotentialRetweet(string id) { var command = new BotCommand() { Value = id, Command = BotCommand.CommandType.RemovePotentialRetweet }; commandRepo.Save(RepoKey, command); return(Json(command, JsonRequestBehavior.AllowGet)); }
public SearchCommand(ISearchFactory factory, string cmdPath) { this.factory = factory; var builder = new CommandBuildInfo( this, Method, new CommandAttribute(cmdPath)); Command = new BotCommand(builder); }
public JsonResult IgnoreTweep(string id) { var command = new BotCommand() { Value = id, Command = BotCommand.CommandType.IgnoreTweep }; commandRepo.Save(RepoKey, command); return(Json(command, JsonRequestBehavior.AllowGet)); }
public JsonResult Refresh() { var command = new BotCommand() { Value = DateTime.Now.ToString(), Command = BotCommand.CommandType.Refresh }; commandRepo.Save(RepoKey, command); return(Json(command, JsonRequestBehavior.AllowGet)); }
public SearchCommand(ISearchResolver resolver, string cmdPath) { this.resolver = resolver; var builder = new CommandBuildInfo( this, Method, new CommandAttribute(cmdPath)); Command = new BotCommand(builder); }
public PlayListCommand(IPlaylistFactory factory, string cmdPath) { this.factory = factory; var builder = new CommandBuildInfo( this, Method, new CommandAttribute(cmdPath)); Command = new BotCommand(builder); }
//logic for actually monitoring channel. private void ControlLoop() { while (!exit) { string currentTextLine = _inputStream.ReadLine(); /* IRC commands come in one of these formats: * :NICK!USER@HOST COMMAND ARGS ... :DATA\r\n * :SERVER COMAND ARGS ... :DATA\r\n */ //Display received irc message Console.WriteLine(currentTextLine); //if (currentTextLine[0] != ':') continue; //Send pong reply to any ping messages if (currentTextLine.StartsWith("PING ")) { _outputStream.Write(currentTextLine.Replace("PING", "PONG") + "\r\n"); _outputStream.Flush(); } else if (currentTextLine[0] != ':') { continue; } else if (BotCommand.isPotentialCommand(currentTextLine)) { BotCommand command = new BotCommand(currentTextLine); TwitchChannel channel = _channels.Find(c => '#' + c.Name == command.Channel); foreach (ICommandHandler handler in _commandHandlers) { CommandHandlerResult result = handler.ProcessCommand(command, channel).Result; bool breakLoop = false; switch (result.ResultType) { case ResultType.Handled: breakLoop = true; break; case ResultType.HandledWithMessage: SendPrivmsg(result.Channel, result.Message); breakLoop = true; break; default: break; } if (breakLoop) { break; } } } } }
private async void OnMessageReceivedAsync(object sender, MessageEventArgs e) { System.Console.WriteLine("Message Received"); if (e.Message.Chat.Id == _settings.MetaCountingChatId) { BotCommand command = new BotCommand(e.Message.Text); if (command.commandType != BotCommandEnum.noCommand) { await _statsManager.HandleStatsCommandAsync(command, e.Message.From.Username, _serviceProvider); return; } } if (e.Message.Chat.Id == _settings.CountingChatId) { MessageEntry messageEntry = new MessageEntry { Username = e.Message.From.Username == null ? e.Message.From.FirstName : e.Message.From.Username, Timestamp = DateTime.UtcNow }; bool isNumberValue = int.TryParse(e.Message.Text, out int number); if (e.Message.Text != null) { isNumberValue &= MoreRobustNumberCheck(e.Message.Text); } if (!isNumberValue || (_lastUserToSendCorrect != null && (_lastUserToSendCorrect == e.Message.From.Username)) || ((_lastNumber != null) && number != _lastNumber + 1)) { _lastUserToSendCorrect = null; _lastNumber = null; messageEntry.Correct = false; messageEntry.Number = -1; await SendMessageAsync(GetRandomInsultMessageForUser( e.Message.From.Username )); } else { _lastNumber = number; _lastUserToSendCorrect = e.Message.From.Username; messageEntry.Correct = true; messageEntry.Number = number; await HandleCoolNumbersAsync(number, e.Message.From.Username); } _stateTimer.Change(_settings.TimerWaitTime, _settings.TimerWaitTime); await _numberStoreRepository.AddNewMessageEntryAsync(_serviceProvider, messageEntry); } }
public EngineCommand PollCommand(Bot bot) { var line = Console.ReadLine(); if (string.IsNullOrWhiteSpace(line)) { return(null); } EngineCommand command = null; var parse = line.Split(' '); switch (parse[0]) { case "settings": command = new SettingsCommand(bot.MatchSettings, parse[1], parse[2]); break; case "update": if (parse[1] == "game") { command = new GameStateCommand(bot.GameState, parse[2], parse[3]); } else { if (bot.MatchSettings.PlayerNames.Contains(parse[1])) { if (!bot.Players.ContainsKey(parse[1])) { bot.Players.Add(parse[1], new PlayerState(bot.MatchSettings.FieldWidth, bot.MatchSettings.FieldHeight)); } var player = bot.Players[parse[1]]; command = new PlayerCommand(player, parse[1], parse[2], parse[3]); } else { Console.WriteLine("Invalid player: '{0}'", parse[1]); } } break; case "action": command = new BotCommand(bot, parse[1], parse[2]); break; } if (command == null) { Console.WriteLine("Invalid command: '{0}'", parse[0]); } return(command); }
public static BotCommand WithRegexGroup( this BotCommand command, GroupCollection group, params string[] parameterNames) { foreach (var parameter in parameterNames) { command = command.Add(parameter, group[parameter].Value); } return(command); }
public PlayListCommand(AudioType audioType, string cmdPath) { this.audioType = audioType; var builder = new CommandBuildInfo( this, playMethod, new CommandAttribute(cmdPath), null); Command = new BotCommand(builder); }
public void ChatBotWarnsOnInvalidCommand() { var cmd = new BotCommand { IsCommand = true, Key = "invalid" }; Mock.Get(this.commandParser).Setup(x => x.Parse("/invalid=code")).Returns(cmd); var result = this.sut.Process("/invalid=code"); Assert.AreEqual("Invalid command. Please use a valid command (Valid commands: stock)", result); }
public PlayCommand(AudioType audioType) { this.audioType = audioType; var builder = new CommandBuildInfo( this, playMethod, new CommandAttribute(CommandRights.Private, string.Empty), null); Command = new BotCommand(builder); }
public void ChatBotProcessesOnlyCommands() { var cmd = new BotCommand() { IsCommand = false }; Mock.Get(this.commandParser).Setup(x => x.Parse("Hello")).Returns(cmd); var result = this.sut.Process("Hello"); Assert.AreEqual(string.Empty, result); }
public Task <BotCommandResult> PutBotCommand(string id, BotCommand command) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException(nameof(id)); } if (command == null) { throw new ArgumentNullException(nameof(command)); } return(BotCommandClient.UpdateAsync(id, command)); }
public void ChatBotRespondsOnCommands() { var cmd = new BotCommand() { IsCommand = true }; Mock.Get(this.commandParser).Setup(x => x.Parse("/stock=code")).Returns(cmd); var result = this.sut.Process("/stock=code"); Assert.AreNotEqual(string.Empty, result); }
public void CreateBotCommand_ConstructorPassedIRCLine_BotCommandCreatedCorrecty() { //Arrange var command = new BotCommand(IRCLine); //Act //Assert Assert.AreEqual("feelthechi", command.Sender); Assert.AreEqual("!quote", command.Command); Assert.AreEqual("5 6 7 8", command.Arguments); Assert.AreEqual("#tminator64", command.Channel); }
private void HandleExpiredCommand(BotCommand cmd, User sender) { RaiseQuoteInquiryResponseReceived( new RfqQuoteInquiryResponse( RfqResponseType.Expired, null, cmd["requestId"], cmd["party"], sender.EmailAddress, null, null, null, null)); }
/// <summary> /// Called when <see cref="commandTimer" /> tick occurs. /// </summary> /// <param name="state">State object.</param> protected async void CommandTimerTick(object?state) { if (this.State != JuvoState.Running) { return; } if (this.commandQueue.Count > 0) { var toRun = new List <IBotCommand>(); lock (this.commandQueue) { IBotCommand cmd; while (this.commandQueue.Count > 0 && (cmd = this.commandQueue.Dequeue()) != null) { toRun.Add(cmd); } } await Task.Run(() => toRun.ForEach(async cmd => await this.ProcessCommand(cmd))); } if (this.commandTimerLastMin != DateTime.Now.Minute && this.plugins.Count > 0) { this.commandTimerLastMin = DateTime.Now.Minute; foreach (var plugin in this.plugins.Values) { if (plugin.CommandTimeMin is null || !plugin.CommandTimeMin.Contains(DateTime.Now.Minute)) { continue; } var src = new CommandSource { SourceType = CommandSourceType.None }; var cmd = new BotCommand(null, CommandTriggerType.Timer, src, string.Empty); await plugin.Execute(cmd, this); // nocommit: how do we know where to send the unsolicited response?? } } lock (this.lastPerfLock) { if (DateTime.Now.Minute % 5 == 0 && DateTime.Now.Second == 0 && (this.lastPerf == null || this.lastPerfTime.AddMinutes(5) < DateTime.UtcNow)) { this.LogPerf(); } } }
Task SendJokeAsync(string joke, BotCommand command, CancellationToken cancellationToken) => _chatHub.Clients .All .SendAsync( "MessageReceived", new { text = joke, id = Guid.NewGuid().ToString(), user = ChatBotUserName, isChatBot = true, sayJoke = command == BotCommand.SayJokes }, cancellationToken);
public EngineCommand PollCommand(Bot bot) { var line = Console.ReadLine(); if (string.IsNullOrWhiteSpace(line)) return null; EngineCommand command = null; var parse = line.Split(' '); switch (parse[0]) { case "settings": command = new SettingsCommand(bot.MatchSettings, parse[1], parse[2]); break; case "update": if (parse[1] == "game") { command = new GameStateCommand(bot.GameState, parse[2], parse[3]); } else { if (bot.MatchSettings.PlayerNames.Contains(parse[1])) { if (!bot.Players.ContainsKey(parse[1])) { bot.Players.Add(parse[1], new PlayerState(bot.MatchSettings.FieldWidth, bot.MatchSettings.FieldHeight)); } var player = bot.Players[parse[1]]; command = new PlayerCommand(player, parse[1], parse[2], parse[3]); } else { Console.WriteLine("Invalid player: '{0}'", parse[1]); } } break; case "action": command = new BotCommand(bot, parse[1], parse[2]); break; } if (command == null) { Console.WriteLine("Invalid command: '{0}'", parse[0]); } return command; }
private void HandleCounterPartyToRequestCommentCommand(BotCommand cmd, User sender) { var comment = ParseComment(cmd); lock (mx_) { if (!requestPartiesTrackingRequestsFromCounterParties_.Contains(comment.RequestParty)) { Logger.InfoFormat("Ignoring comment for {0}, not subscribed as this party for counter party comments", comment.RequestParty); return; } } RaiseCounterPartyCommentReceived(comment); }
private void HandleErrorCommand(BotCommand cmd, User sender) { // error [email protected]:1 Wrong RFQ request RaiseQuoteInquiryResponseReceived( new RfqQuoteInquiryResponse( RfqResponseType.Error, cmd["message"], cmd["requestId"], cmd["party"], sender.EmailAddress, null, null, null, null)); }
private string BuildCallData(string CommandName, params int[] Argument) { BotCommand command = new BotCommand { Cmd = CommandName, Arg = new List <int>() }; for (int i = 0; i < Argument.Length; i++) { command.Arg.Add(Argument[i]); } return(JsonConvert.SerializeObject(command)); }
public void EmmitBotCommand(BotCommand cmd) { try { BotManager manager = FindBotManager(cmd.BotDesc); if (manager == null) return; manager.EmmitBotCommand(cmd); } catch (Exception e) { AppContext.WriteLog(e.Message); return; } }
public void ReceiveCommand(BotCommand command) { switch (command.Key) { case "moves": var moves = MovesForRound(int.Parse(command.Value)); if (moves.Length == 0) { Console.WriteLine("no_moves"); } else { Console.WriteLine("{0},drop", string.Join(",", moves).ToLower()); } break; default: Console.WriteLine("Invalid bot command: {0}", command.Key); break; } }
public void SetCommand(BotCommand cmd) { this.cmd = cmd.ToString(); }
public RemindWhenMoreRequirementsNeedsToBeApproved(IGitHubClient client, Repository repository, BotCommand.IResponse response) { this.client = client; this.repository = repository; this.response = response; }
public BotEvent_Command(BotCommand cmd) { command = cmd.CommandName; id = (int)EventID.BOT_EVENT_ON_COMMAND; parameters = new Dictionary<string, string>(); foreach (BotCommand.Parameter param in cmd.Parameters) { parameters[param.Name] = param.Value; } }