private void ProcessTextToSpeechEvent(TextToSpeechEvent message) { if (message is SpeakEvent) { ChannelUser user = message.User; Speak(message.User, u => $"{u.Username} sagt {message.Message}"); return; } Speak(message.Message); }
public BotMessage ProcessCommand(string user, string message) { message = message.Trim(); if (LogMessages) { Console.WriteLine($"{user}: {message}"); } if (message.StartsWith("!")) { string command = message.GetMatches(@"^!\w+").FirstOrDefault(); string data = message.GetMatches(@"(?<=\b[\s]).+").FirstOrDefault(); if (string.IsNullOrEmpty(command?.TrimStart('!')) || !commandList.Contains(command) && !soundCommandList.ContainsKey(command?.TrimStart('!'))) { return new BotMessage { Type = BotMessageType.NotCommand } } ; switch (command) { case "!привет": return(new BotMessage { Text = $"Привет, {user}!", Type = BotMessageType.Success }); case "!озвучить": if (DateTime.Now < lastSound.AddSeconds(SoundTimeout)) { return new BotMessage { Type = BotMessageType.Error } } ; string id = TextToSpeech(data); TextToSpeechEvent?.Invoke(new TextToSpeechEventArgs { FileName = id }); lastSound = DateTime.Now; break; case "!time": return(new BotMessage { Text = $"Время в эфире: {DateTime.Now}", Type = BotMessageType.Success }); case "!sr": case "!заказ": string result = Rocksmith.AddTrack(data, user); return(new BotMessage { Type = BotMessageType.Success, Text = result }); default: if (soundCommandList.ContainsKey(command.TrimStart('!'))) { if (DateTime.Now < lastSound.AddSeconds(SoundTimeout)) { return new BotMessage { Type = BotMessageType.Error } } ; SoundMessageEvent?.Invoke(new SoundMessageEventArgs { FileName = command.TrimStart('!') }); lastSound = DateTime.Now; } break; } return(new BotMessage { Type = BotMessageType.Success }); } return(new BotMessage { Type = BotMessageType.NotCommand }); }