protected async Task <string> ReplaceStringWithSpecialModifiers(string str, CommandParametersModel parameters) { SpecialIdentifierStringBuilder siString = new SpecialIdentifierStringBuilder(str, encode: false); await siString.ReplaceCommonSpecialModifiers(parameters); return(siString.ToString()); }
private async void SendChatMessageButton_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(this.ChatMessageTextBox.Text)) { string message = this.ChatMessageTextBox.Text; if (message.Contains(SpecialIdentifierStringBuilder.SpecialIdentifierHeader)) { SpecialIdentifierStringBuilder spReplacement = new SpecialIdentifierStringBuilder(message, Guid.NewGuid()); await spReplacement.ReplaceCommonSpecialModifiers(await ChannelSession.GetCurrentUser()); message = spReplacement.ToString(); } if (messageHistory.Contains(message)) { // Remove so we can move to the end messageHistory.Remove(message); } messageHistory.Add(message); activeMessageHistory = messageHistory.Count; this.ChatMessageTextBox.Text = string.Empty; if (ChatAction.WhisperRegex.IsMatch(message)) { Match whisperRegexMatch = ChatAction.WhisperRegex.Match(message); message = message.Substring(whisperRegexMatch.Value.Length); Match usernNameMatch = ChatAction.UserNameTagRegex.Match(whisperRegexMatch.Value); string username = usernNameMatch.Value; username = username.Trim(); username = username.Replace("@", ""); await this.Window.RunAsyncOperation(async() => { ChatMessageEventModel response = await ChannelSession.Chat.WhisperWithResponse(username, message, ShouldSendAsStreamer()); if (response != null) { await this.AddMessage(ChatMessageViewModel.CreateChatMessageViewModel(response)); } }); } else if (ChatAction.ClearRegex.IsMatch(message)) { await ChannelSession.Chat.ClearMessages(); } else { await this.Window.RunAsyncOperation((Func <Task>)(async() => { await ChannelSession.Chat.SendMessage(message, ShouldSendAsStreamer()); })); } this.ChatMessageTextBox.Focus(); } }
private async Task <string> ReplaceSpecialIdentifiers(string text, UserViewModel user, IEnumerable <string> arguments, string webRequestResult) { SpecialIdentifierStringBuilder siString = new SpecialIdentifierStringBuilder(this.ResponseChatText); await siString.ReplaceCommonSpecialModifiers(user, arguments); siString.ReplaceSpecialIdentifier(WebRequestAction.ResponseSpecialIdentifier, webRequestResult); return(siString.ToString()); }
protected async Task<string> ReplaceStringWithSpecialModifiers(string str, UserViewModel user, IEnumerable<string> arguments) { SpecialIdentifierStringBuilder siString = new SpecialIdentifierStringBuilder(str); await siString.ReplaceCommonSpecialModifiers(user, arguments); foreach (var kvp in this.AdditiveSpecialIdentifiers) { siString.ReplaceSpecialIdentifier(kvp.Key, kvp.Value); } return siString.ToString(); }
protected async Task <string> ReplaceStringWithSpecialModifiers(string str, UserViewModel user, IEnumerable <string> arguments, bool encode = false) { SpecialIdentifierStringBuilder siString = new SpecialIdentifierStringBuilder(str, this.randomUserSpecialIdentifierGroup, encode); await siString.ReplaceCommonSpecialModifiers(user, arguments); foreach (var kvp in this.additiveSpecialIdentifiers) { siString.ReplaceSpecialIdentifier(kvp.Key, kvp.Value); } return(siString.ToString()); }
protected async Task <string> ReplaceStringWithSpecialModifiers(string str, CommandParametersModel parameters, bool encode = false) { SpecialIdentifierStringBuilder siString = new SpecialIdentifierStringBuilder(str, encode); foreach (var kvp in this.extraSpecialIdentifiers) { siString.ReplaceSpecialIdentifier(kvp.Key, kvp.Value); } await siString.ReplaceCommonSpecialModifiers(parameters); return(siString.ToString()); }
protected async Task <string> ReplaceStringWithSpecialModifiers(string str, UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers) { SpecialIdentifierStringBuilder siString = new SpecialIdentifierStringBuilder(str, encode: false); if (extraSpecialIdentifiers != null) { foreach (var kvp in extraSpecialIdentifiers) { siString.ReplaceSpecialIdentifier(kvp.Key, kvp.Value); } } await siString.ReplaceCommonSpecialModifiers(user, arguments); return(siString.ToString()); }