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);
}
代码是C#,它在所有session.Add()和cleverbot.Add()语句中给出了null引用错误,我无法弄清楚为什么(cleverbot和session是dictionarys)
答案 0 :(得分:0)
字典没有正确初始化