private void TalkCallback(IrcMessageEventArgs message) { var channel = message.Targets.First().Name; var talker = new TalkBehaviour(_markovChainString); var sentence = talker.GenerateRandomSentence(); var parameters = GetParameters(message.Text); ReinitializeFromParameters(talker, ref channel, ref sentence, parameters); var reply = message.CreateReply(sentence); SendMessage(channel, reply); }
private static void ReinitializeFromParameters(TalkBehaviour talker, ref string channel, ref string sentence, IEnumerable <string> parameters) { if (parameters.Count() < 3 || parameters.Skip(1).ToString().ToLower() != "about") { return; } var talkAboutWords = RemoveFirstKeywords(2, parameters); if (talkAboutWords.Last().StartsWith("#")) { channel = parameters.Last(); talkAboutWords = RemoveChannelName(talkAboutWords); } sentence = talker.GenerateRandomSentenceFrom(talkAboutWords); }
public static MarkovChainString Load(Config parameters, Action <string> output) { output?.Invoke($"Loading '{parameters.Load}'"); var markovChainString = new MarkovChainString(); var loadBehaviour = new LoadBehaviour(markovChainString, parameters.Load); var talkBehaviour = new TalkBehaviour(markovChainString); output?.Invoke($"Generating samples"); loadBehaviour.Process(); Enumerable.Range(0, parameters.Samples).ForEach(i => { var sample = talkBehaviour.GenerateRandomSentence(); output?.Invoke($"{i}: '{sample}'"); }); return(markovChainString); }