using vnxbqy.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
using UnityEngine;
|
|
|
public class LanguageVerify : Singleton<LanguageVerify>
|
|
{
|
const string Sercret = "c345a165b566d1c421afd8a748373d7f";
|
|
static StringBuilder sb = new StringBuilder();
|
|
/// <summary>
|
/// 校验玩家名
|
/// </summary>
|
/// <param name="verifyName">需要检验的名字</param>
|
/// <param name="playerId">玩家id</param>
|
/// <param name="playerName">原来的角色名,创角传空</param>
|
/// <param name="level">玩家等级</param>
|
/// <param name="vipLv">玩家VIP等级</param>
|
/// <param name="callback"></param>
|
public void VerifyPlayerName(string verifyName, int playerId, string playerName, int level, int vipLv, Action<bool, string> callback)
|
{
|
if (callback != null)
|
{
|
callback(true, verifyName);
|
callback = null;
|
}
|
return;
|
}
|
|
public void VerifyFairy(string verifyContent, int op_type, string fairyName, int title, Action<bool, string> callback)
|
{
|
if (callback != null)
|
{
|
callback(true, verifyContent);
|
callback = null;
|
}
|
return;
|
}
|
|
public static uint toPlayer = 0;
|
public static string toPlayerName = string.Empty;
|
public static int toPlayerLevel = 0;
|
public void VerifyChat(string content, ChatInfoType channelType, Action<bool, string> callback)
|
{
|
int channel = 0;
|
var chatCenter = ModelCenter.Instance.GetModel<ChatCenter>();
|
if (chatCenter.IsChatBanned || chatCenter.IsClientBan(channelType))
|
{
|
if (!(IsFairyFeast(channelType) || IsSystemChat(content)))
|
{
|
return;
|
}
|
}
|
|
if (!GetChannel(channelType, out channel))
|
{
|
return;
|
}
|
if (callback != null)
|
{
|
callback(true, content);
|
callback = null;
|
}
|
|
}
|
|
Dictionary<long, List<string>> transferContents = new Dictionary<long, List<string>>();
|
Dictionary<long, List<int>> splitContents = new Dictionary<long, List<int>>();
|
|
List<MatchString> matchs = new List<MatchString>();
|
|
struct MatchString
|
{
|
public int index;
|
public string value;
|
}
|
|
void AddMathcs(MatchCollection _matchs)
|
{
|
if (_matchs.Count == 0)
|
{
|
return;
|
}
|
foreach (Match match in _matchs)
|
{
|
matchs.Add(new MatchString()
|
{
|
index = match.Index,
|
value = match.Value,
|
});
|
}
|
}
|
|
string TransferContent(long tick, string content)
|
{
|
List<string> list;
|
List<int> splits;
|
if (!transferContents.TryGetValue(tick, out list))
|
{
|
list = new List<string>();
|
transferContents.Add(tick, list);
|
}
|
if (!splitContents.TryGetValue(tick, out splits))
|
{
|
splits = new List<int>();
|
splitContents.Add(tick, splits);
|
}
|
list.Clear();
|
splits.Clear();
|
matchs.Clear();
|
AddMathcs(WordAnalysis.Color_Start_Regex.Matches(content));
|
AddMathcs(WordAnalysis.Color_End_Regex.Matches(content));
|
AddMathcs(ImgAnalysis.FaceRegex.Matches(content));
|
AddMathcs(ChatCtrl.InviteRegex.Matches(content));
|
AddMathcs(WordAnalysis.Size_Start_Regex.Matches(content));
|
AddMathcs(WordAnalysis.Size_End_Regex.Matches(content));
|
AddMathcs(WordAnalysis.Space_Regex.Matches(content));
|
AddMathcs(ChatCtrl.KillRegex.Matches(content));
|
AddMathcs(ChatCenter.s_VoiceRegex.Matches(content));
|
matchs.Sort((x, y) =>
|
{
|
return x.index.CompareTo(y.index);
|
});
|
var index = 0;
|
for (int i = 0; i < matchs.Count; i++)
|
{
|
list.Add(matchs[i].value);
|
var length = matchs[i].index - index;
|
splits.Add(length);
|
index += length + matchs[i].value.Length;
|
}
|
content = WordAnalysis.Color_Start_Regex.Replace(content, string.Empty);
|
content = WordAnalysis.Color_End_Regex.Replace(content, string.Empty);
|
content = ImgAnalysis.FaceRegex.Replace(content, string.Empty);
|
content = ChatCtrl.InviteRegex.Replace(content, string.Empty);
|
content = WordAnalysis.Size_Start_Regex.Replace(content, string.Empty);
|
content = WordAnalysis.Size_End_Regex.Replace(content, string.Empty);
|
content = WordAnalysis.Space_Regex.Replace(content, string.Empty);
|
content = ChatCtrl.KillRegex.Replace(content, string.Empty);
|
content = ChatCenter.s_VoiceRegex.Replace(content, string.Empty);
|
return content;
|
}
|
|
string DisTransfer(long tick, string content)
|
{
|
List<string> list;
|
if (!transferContents.TryGetValue(tick, out list))
|
{
|
return content;
|
}
|
List<int> splits;
|
if (!splitContents.TryGetValue(tick, out splits))
|
{
|
return content;
|
}
|
var index = 0;
|
sb.Length = 0;
|
for (int i = 0; i < splits.Count; i++)
|
{
|
sb.Append(content.Substring(index, splits[i]));
|
if (i < list.Count)
|
{
|
sb.Append(list[i]);
|
}
|
index += splits[i];
|
}
|
sb.Append(content.Substring(index));
|
transferContents.Remove(tick);
|
splitContents.Remove(tick);
|
return sb.ToString();
|
}
|
|
bool IsSystemChat(string content)
|
{
|
if (ChatCtrl.InviteRegex.IsMatch(content)
|
|| ChatCtrl.KillRegex.IsMatch(content))
|
{
|
return true;
|
}
|
return false;
|
}
|
|
bool GetChannel(ChatInfoType type, out int channel)
|
{
|
channel = 0;
|
switch (type)
|
{
|
case ChatInfoType.World:
|
case ChatInfoType.CrossServer:
|
channel = 0;
|
break;
|
case ChatInfoType.Team:
|
channel = 4;
|
break;
|
case ChatInfoType.Area:
|
case ChatInfoType.Trumpet:
|
case ChatInfoType.default1:
|
channel = 5;
|
break;
|
case ChatInfoType.Fairy:
|
channel = 2;
|
break;
|
case ChatInfoType.Friend:
|
channel = 3;
|
break;
|
default:
|
return false;
|
}
|
return true;
|
}
|
|
bool IsFairyFeast(ChatInfoType type)
|
{
|
var dailyQuestModel = ModelCenter.Instance.GetModel<DailyQuestModel>();
|
DailyQuestOpenTime dailyQuestOpenTime;
|
if (dailyQuestModel.TryGetOpenTime((int)DailyQuestType.FairyFeast, out dailyQuestOpenTime))
|
{
|
return type == ChatInfoType.Fairy && dailyQuestOpenTime.InOpenTime();
|
}
|
return false;
|
}
|
|
public class VerifyResponse
|
{
|
public string result;
|
public int code;
|
public string content;
|
}
|
}
|