少年修仙传客户端代码仓库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
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;
    }
}