예제 #1
0
 /// <summary>
 /// 教学
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 private string TeachAction(string message)
 {
     //将称谓换掉
     message = message.Replace(Settings.NekoName, "$(name)");
     var groups = AnalyseRegex.Teach.Match(message).Groups;
     //问题
     var key = groups[1].Value;
     //答案
     var value = groups[2].Value;
     var item = new Lexicon { LxKey = key, LxValue = value, LxType = Convert.ToInt16(key.Contains("*") ? 1 : 0), Time = Convert.ToDateTime("1900-01-01 00:00:00.000") };
     if (item.LxType == 1 && item.LxKey.Replace("*", "").Trim().Length == 0)
     {
         //只有通配符
         return ConstString("MeetAllError");
     }
     if (RunTime.Database.Lexicon.Any(p => p.LxKey == item.LxKey && p.LxValue == item.LxValue))
     {
         //词库已存在
         return ConstString("LexiconExistsError");
     }
     RunTime.Database.Lexicon.InsertOnSubmit(item);
     RunTime.Database.SubmitChanges();
     //教学成功
     return ConstString("Success");
 }
예제 #2
0
 /// <summary>
 /// 正则教学
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public string RegexAction(string message)
 {
     //将称谓换掉
     message = message.Replace(Settings.NekoName, "$(name)");
     var groups = AnalyseRegex.Regex.Match(message).Groups;
     //问题
     var key = groups[1].Value;
     //答案
     var value = groups[2].Value;
     var item = new Lexicon { LxKey = key, LxValue = value, LxType = 2 };
     if (RunTime.Database.Lexicon.Any(p => p.LxKey == item.LxKey && p.LxValue == item.LxValue))
     {
         return ConstString("LexiconExistsError");
     }
     RunTime.Database.Lexicon.InsertOnSubmit(item);
     RunTime.Database.SubmitChanges();
     return ConstString("Success");
 }
예제 #3
0
 partial void DeleteLexicon(Lexicon instance);
예제 #4
0
 partial void UpdateLexicon(Lexicon instance);
예제 #5
0
 partial void InsertLexicon(Lexicon instance);