private void GoogleTalkClient_OnMessage(object sender, jabber.protocol.client.Message msg)
{
connectionsNumber.Maximum = rosterManager.Count;
if (session.Keys.Contains<string>(msg.From.Bare)){
session.TryGetValue(msg.From.Bare,out thissession);
}else{
if (cleverbot.Keys.Contains<string>(msg.From.Bare)){
cleverbot.TryGetValue(msg.From.Bare,out bot);
}else{
bot = factory.Create(ChatterBotType.CLEVERBOT);
if (bot != null)
cleverbot.Add(msg.From.Bare, bot);
}
thissession = bot.CreateSession();
if (thissession != null)
session.Add(msg.From.Bare, thissession);
}
connectionsNumber.Value = session.Count;
jabber.protocol.client.Message reply = new jabber.protocol.client.Message(GoogleTalkClient.Document);
reply.Body = thissession.Think(Grammarcheck(msg.Body));
reply.To = msg.From;
GoogleTalkClient.Write(reply);
}
the code is C# and it is giving me nullreference errors on all of the session.Add() and cleverbot.Add() statements and i can’t figure out why (cleverbot and session are dictionarys)
The Dictionaries were not properly initialized