public void GetSpamPoints(TgMessage RawMessage) { int spacePath = RawMessage.text.IndexOf(" "); if (spacePath == -1) { TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, "/getspampoints 被檢測訊息", //"/getspampoints text=\"被檢測訊息,如果包含英文與數字以外的文字需要加引號\"" + //" rule=\"規則的暱稱,如果包含英文與數字以外的文字需要加引號\"", RawMessage.message_id ); return; } //Dictionary<string, string> banValues = // CommandDecoder.cutKeyIsValue(RawMessage.text.Substring(spacePath + 1)); string text = RawMessage.text.Replace("/getspampoints ", ""); //string text = banValues.GetValueOrDefault("text", null); //string rule = banValues.GetValueOrDefault("rule", null); if (text == null) { TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, "你的輸入有錯誤", RawMessage.message_id ); return; } //if (rule == null) //{ List <SpamMessage> spamMsgList = Temp.GetDatabaseManager().GetSpamMessageList(); string msg = ""; bool found = false; foreach (SpamMessage smsg in spamMsgList) { int points = 0; switch (smsg.Type) { case 0: points = new SpamMessageChecker().GetEqualsPoints(smsg.Messages, text); break; case 1: points = new SpamMessageChecker().GetRegexPoints(smsg.Messages, text); break; case 2: points = new SpamMessageChecker().GetSpamPoints(smsg.Messages, text); break; case 3: points = new SpamMessageChecker().GetIndexOfPoints(smsg.Messages, text); break; case 4: points = new SpamMessageChecker().GetHalalPoints(text); break; case 5: points = new SpamMessageChecker().GetIndiaPoints(text); break; case 6: points = new SpamMessageChecker().GetContainsPoints(smsg.Messages, text); break; case 7: points = new SpamMessageChecker().GetRussiaPoints(text); break; case 8: points = new SpamMessageChecker().GetNamePoints(smsg.Messages, text); break; } if (points > 0) { found = true; msg = msg + smsg.FriendlyName + " : " + points + "\n"; } } if (found) { TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, msg, RawMessage.message_id ); } else { TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, "未得分", RawMessage.message_id ); } //} //else //{ // SpamMessage smsg = Temp.GetDatabaseManager().GetSpamRule(rule); // if (smsg == null) // { // TgApi.getDefaultApiConnection().sendMessage( // RawMessage.GetMessageChatInfo().id, // "没有找到您指定的规則,請重新指定。您可使用 /getspamstr 獲取所以規則。", // RawMessage.message_id // ); // return; // } // // int points = 0; // switch (smsg.Type) // { // case 0: // points = new SpamMessageChecker().GetEqualsPoints(smsg.Messages, text); // break; // case 1: // points = new SpamMessageChecker().GetRegexPoints(smsg.Messages, text); // break; // case 2: // points = new SpamMessageChecker().GetSpamPoints(smsg.Messages, text); // break; // case 3: // points = new SpamMessageChecker().GetIndexOfPoints(smsg.Messages, text); // break; // case 4: // points = new SpamMessageChecker().GetHalalPoints(text); // break; // case 5: // points = new SpamMessageChecker().GetIndiaPoints(text); // break; // case 6: // points = new SpamMessageChecker().GetContainsPoints(smsg.Messages, text); // break; // case 7: // points = new SpamMessageChecker().GetRussiaPoints(text); // break; // } // // TgApi.getDefaultApiConnection().sendMessage( // RawMessage.GetMessageChatInfo().id, // "得分: " + points, // RawMessage.message_id // ); //} }
public void GetSpamPoints(TgMessage RawMessage) { int spacePath = RawMessage.text.IndexOf(" "); if (spacePath == -1) { TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, "/getspampoints text=\"被检测消息,如果包含英文和数字以外的字符需要加引号\"" + " rule=\"规则的友好名称,如果包含英文和数字以外的字符需要加引号\"", RawMessage.message_id ); return; } Dictionary <string, string> banValues = CommandDecoder.cutKeyIsValue(RawMessage.text.Substring(spacePath + 1)); string text = banValues.GetValueOrDefault("text", null); string rule = banValues.GetValueOrDefault("rule", null); if (text == null || rule == null) { TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, "您的输入有误", RawMessage.message_id ); return; } SpamMessage smsg = Temp.GetDatabaseManager().GetSpamRule(rule); if (smsg == null) { TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, "没有找到您指定的规则,请重新指定。您亦可使用 /getspamstr 获取所有规则。", RawMessage.message_id ); return; } int points = 0; switch (smsg.Type) { case 0: points = new SpamMessageChecker().GetEqualsPoints(smsg.Messages, text); break; case 1: points = new SpamMessageChecker().GetRegexPoints(smsg.Messages, text); break; case 2: points = new SpamMessageChecker().GetSpamPoints(smsg.Messages, text); break; case 3: points = new SpamMessageChecker().GetIndexOfPoints(smsg.Messages, text); break; case 4: points = new SpamMessageChecker().GetHalalPoints(text); break; case 5: points = new SpamMessageChecker().GetIndiaPoints(text); break; } TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, "得分: " + points, RawMessage.message_id ); }