WXUserReader.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. using K4os.Compression.LZ4.Encoders;
  2. using K4os.Compression.LZ4;
  3. using SQLite;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Net.Mime;
  11. using System.Security.Cryptography;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Interop;
  15. using System.Windows.Media.Imaging;
  16. using System.Xml;
  17. using System.Xml.Linq;
  18. using WechatBakTool.Helpers;
  19. using WechatBakTool.Model;
  20. using System.Windows;
  21. using System.Net.Http;
  22. using System.Reflection.Metadata;
  23. using System.Threading;
  24. using Newtonsoft.Json;
  25. namespace WechatBakTool
  26. {
  27. public class WXUserReader
  28. {
  29. private Dictionary<string, SQLiteConnection> DBInfo = new Dictionary<string, SQLiteConnection>();
  30. private UserBakConfig? UserBakConfig = null;
  31. private Hashtable HeadImgCache = new Hashtable();
  32. private Hashtable UserNameCache = new Hashtable();
  33. private Hashtable EmojiCache = new Hashtable();
  34. private HttpClient httpClient = new HttpClient();
  35. public WXUserReader(UserBakConfig userBakConfig) {
  36. string path = Path.Combine(userBakConfig.UserWorkspacePath, "DecDB");
  37. UserBakConfig = userBakConfig;
  38. LoadDB(path);
  39. InitCache();
  40. EmojiCacheInit();
  41. }
  42. public void LoadDB(string path)
  43. {
  44. string[] dbFileList = Directory.GetFiles(path);
  45. foreach (var item in dbFileList)
  46. {
  47. FileInfo fileInfo = new FileInfo(item);
  48. if (fileInfo.Extension != ".db")
  49. continue;
  50. SQLiteConnection con = new SQLiteConnection(item);
  51. string dbName = fileInfo.Name.Split('.')[0];
  52. DBInfo.Add(dbName, con);
  53. }
  54. }
  55. private SQLiteConnection? getCon(string name)
  56. {
  57. if (DBInfo.ContainsKey(name))
  58. {
  59. return DBInfo[name];
  60. }
  61. else
  62. {
  63. return null;
  64. }
  65. }
  66. public void InitCache()
  67. {
  68. SQLiteConnection? con = getCon("Misc");
  69. if (con == null)
  70. return;
  71. string query = @"SELECT * FROM ContactHeadImg1";
  72. List<ContactHeadImg> imgs = con.Query<ContactHeadImg>(query);
  73. foreach(ContactHeadImg item in imgs)
  74. {
  75. if (!HeadImgCache.ContainsKey(item.usrName))
  76. {
  77. HeadImgCache.Add(item.usrName, item);
  78. }
  79. }
  80. List<WXContact> contacts = GetWXContacts(null, true).ToList();
  81. foreach(WXContact contact in contacts)
  82. {
  83. if (!UserNameCache.ContainsKey(contact.UserName))
  84. UserNameCache.Add(contact.UserName, contact);
  85. }
  86. }
  87. public void EmojiCacheInit()
  88. {
  89. string emoji_path = Path.Combine(UserBakConfig!.UserWorkspacePath, "Emoji");
  90. if (Directory.Exists(emoji_path))
  91. {
  92. string[] files = Directory.GetFiles(emoji_path);
  93. foreach (string file in files)
  94. {
  95. FileInfo fileInfo = new FileInfo(file);
  96. string[] names = fileInfo.Name.Split(".");
  97. if (!EmojiCache.ContainsKey(names[0]))
  98. {
  99. EmojiCache.Add(names[0], 1);
  100. }
  101. }
  102. }
  103. }
  104. public void PreDownloadEmoji(string username = "")
  105. {
  106. if (UserBakConfig == null)
  107. return;
  108. HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate };
  109. HttpClient httpClient = new HttpClient(handler);
  110. List<WXMsg> msgs = GetTypeMsg("47", username);
  111. int i = 0;
  112. // 下载前的Emoji Cache不用做了,在Init的时候已经做了
  113. foreach (var msg in msgs)
  114. {
  115. i++;
  116. if (i % 5 == 0)
  117. {
  118. // 每5次让下载线程休息1秒
  119. Thread.Sleep(1000);
  120. }
  121. try
  122. {
  123. XmlDocument xmlDocument = new XmlDocument();
  124. xmlDocument.LoadXml(msg.StrContent);
  125. XmlNode? node = xmlDocument.SelectSingleNode("/msg/emoji");
  126. if (node != null)
  127. {
  128. if (node.Attributes != null)
  129. {
  130. string type = "";
  131. string md5 = "";
  132. string url = "";
  133. XmlNode? item = node.Attributes.GetNamedItem("type");
  134. type = item != null ? item.InnerText : "";
  135. item = node.Attributes.GetNamedItem("md5");
  136. md5 = item != null ? item.InnerText : "";
  137. item = node.Attributes.GetNamedItem("cdnurl");
  138. url = item != null ? item.InnerText : "";
  139. if (EmojiCache.ContainsKey(md5))
  140. {
  141. i--;
  142. continue;
  143. }
  144. if (url == "")
  145. {
  146. i--;
  147. continue;
  148. }
  149. else
  150. {
  151. string path = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Emoji", md5 + ".gif");
  152. try
  153. {
  154. HttpResponseMessage res = httpClient.GetAsync(url).Result;
  155. if (res.IsSuccessStatusCode)
  156. {
  157. using (FileStream fs = File.Create(path))
  158. {
  159. res.Content.ReadAsStream().CopyTo(fs);
  160. }
  161. }
  162. }
  163. catch (Exception ex)
  164. {
  165. }
  166. }
  167. }
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. }
  173. }
  174. // 下载完成后可能变化,检查一下
  175. EmojiCacheInit();
  176. }
  177. public byte[]? GetHeadImgCahce(string username)
  178. {
  179. if (HeadImgCache.ContainsKey(username))
  180. {
  181. ContactHeadImg? img = HeadImgCache[username] as ContactHeadImg;
  182. if (img == null)
  183. return null;
  184. else
  185. return img.smallHeadBuf;
  186. }
  187. return null;
  188. }
  189. public int[] GetWXCount()
  190. {
  191. SQLiteConnection? con = getCon("MicroMsg");
  192. if (con == null)
  193. return new int[] { 0, 0 };
  194. string query = @"select count(*) as count from contact where type != 4";
  195. int userCount = con.Query<WXCount>(query)[0].Count;
  196. int msgCount = 0;
  197. for (int i = 0; i <= 99; i++)
  198. {
  199. con = getCon("MSG" + i.ToString());
  200. if (con == null)
  201. return new int[] { userCount, msgCount };
  202. query = "select count(*) as count from MSG";
  203. msgCount += con.Query<WXCount>(query)[0].Count;
  204. }
  205. return new int[] { userCount, msgCount };
  206. }
  207. public ObservableCollection<WXContact> GetWXContacts(string? name = null,bool all = false)
  208. {
  209. SQLiteConnection? con = getCon("MicroMsg");
  210. if (con == null)
  211. return new ObservableCollection<WXContact>();
  212. string query = @"select contact.*,session.strContent,contactHeadImgUrl.smallHeadImgUrl,contactHeadImgUrl.bigHeadImgUrl from contact
  213. left join session on session.strUsrName = contact.username
  214. left join contactHeadImgUrl on contactHeadImgUrl.usrName = contact.username
  215. where type != 4 {searchName}
  216. order by nOrder desc";
  217. if (all)
  218. {
  219. query = query.Replace("where type != 4 ", "");
  220. }
  221. List<WXContact>? contacts = null;
  222. if (name != null)
  223. {
  224. query = query.Replace("{searchName}", " and (username like ? or alias like ? or nickname like ? or remark like ?)");
  225. contacts = con.Query<WXContact>(query, $"%{name}%", $"%{name}%", $"%{name}%", $"%{name}%");
  226. }
  227. else
  228. {
  229. query = query.Replace("{searchName}", "");
  230. contacts = con.Query<WXContact>(query);
  231. }
  232. foreach (WXContact contact in contacts)
  233. {
  234. if(contact.Remark != "")
  235. contact.NickName = contact.Remark;
  236. byte[]? imgBytes = GetHeadImgCahce(contact.UserName);
  237. if (imgBytes != null)
  238. {
  239. try
  240. {
  241. MemoryStream stream = new MemoryStream(imgBytes);
  242. BitmapImage bitmapImage = new BitmapImage();
  243. bitmapImage.BeginInit();
  244. bitmapImage.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
  245. bitmapImage.StreamSource = stream;
  246. bitmapImage.EndInit();
  247. bitmapImage.Freeze();
  248. contact.Avatar = bitmapImage;
  249. }
  250. catch
  251. {
  252. #if DEBUG
  253. File.AppendAllText("debug.log", string.Format("[D]{0} {1}:{2}\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "BitmapConvert Err=>Length", imgBytes.Length));
  254. #endif
  255. }
  256. }
  257. else
  258. continue;
  259. }
  260. return new ObservableCollection<WXContact>(contacts);
  261. }
  262. public List<WXUserImg>? GetUserImgs()
  263. {
  264. SQLiteConnection? con = getCon("MicroMsg");
  265. if (con == null)
  266. return null;
  267. string query = "select * from contactHeadImgUrl";
  268. return con.Query<WXUserImg>(query);
  269. }
  270. public List<WXChatRoom>? GetWXChatRooms()
  271. {
  272. SQLiteConnection? con = getCon("MicroMsg");
  273. if (con == null)
  274. return null;
  275. string query = "select * from ChatRoom";
  276. return con.Query<WXChatRoom>(query);
  277. }
  278. public List<WXMsg> GetTypeMsg(string type,string username)
  279. {
  280. List<WXMsg> tmp = new List<WXMsg>();
  281. for (int i = 0; i <= 99; i++)
  282. {
  283. SQLiteConnection? con = getCon("MSG" + i.ToString());
  284. if (con == null)
  285. return tmp;
  286. List<WXMsg> wXMsgs;
  287. if (username == "")
  288. {
  289. string query = "select * from MSG where Type=?";
  290. wXMsgs = con.Query<WXMsg>(query, type);
  291. }
  292. else
  293. {
  294. string query = "select * from MSG where Type=? and StrTalker = ?";
  295. wXMsgs = con.Query<WXMsg>(query, type, username);
  296. }
  297. tmp.AddRange(wXMsgs);
  298. }
  299. return tmp;
  300. }
  301. public List<WXMsg>? GetWXMsgs(string uid,string msg = "")
  302. {
  303. List<WXMsg> tmp = new List<WXMsg>();
  304. for (int i = 0; i <= 99; i++)
  305. {
  306. SQLiteConnection? con = getCon("MSG" + i.ToString());
  307. if (con == null)
  308. return tmp;
  309. List<WXMsg>? wXMsgs = null;
  310. if (msg == "")
  311. {
  312. string query = "select * from MSG where StrTalker=?";
  313. wXMsgs = con.Query<WXMsg>(query, uid);
  314. }
  315. else if (uid == "")
  316. {
  317. string query = "select * from MSG where StrContent like ?";
  318. wXMsgs = con.Query<WXMsg>(query, string.Format("%{0}%", msg));
  319. }
  320. else
  321. {
  322. string query = "select * from MSG where StrTalker=? and StrContent like ?";
  323. wXMsgs = con.Query<WXMsg>(query, uid, string.Format("%{0}%", msg));
  324. }
  325. foreach (WXMsg w in wXMsgs)
  326. {
  327. if (UserNameCache.ContainsKey(w.StrTalker))
  328. {
  329. WXContact? contact = UserNameCache[w.StrTalker] as WXContact;
  330. if (contact != null)
  331. {
  332. if (contact.Remark != "")
  333. w.NickName = contact.Remark;
  334. else
  335. w.NickName = contact.NickName;
  336. w.StrTalker = contact.UserName;
  337. }
  338. }
  339. else
  340. {
  341. w.NickName = uid;
  342. }
  343. // 群聊处理
  344. if (uid.Contains("@chatroom"))
  345. {
  346. string userId = "";
  347. if (w.BytesExtra == null)
  348. continue;
  349. string sl = BitConverter.ToString(w.BytesExtra).Replace("-", "");
  350. ProtoMsg protoMsg;
  351. using (MemoryStream stream = new MemoryStream(w.BytesExtra))
  352. {
  353. protoMsg = ProtoBuf.Serializer.Deserialize<ProtoMsg>(stream);
  354. }
  355. if (protoMsg.TVMsg != null)
  356. {
  357. foreach (TVType _tmp in protoMsg.TVMsg)
  358. {
  359. if (_tmp.Type == 1)
  360. userId = _tmp.TypeValue;
  361. }
  362. }
  363. if (!w.IsSender)
  364. {
  365. if (UserNameCache.ContainsKey(userId))
  366. {
  367. WXContact? contact = UserNameCache[userId] as WXContact;
  368. if (contact != null)
  369. w.NickName = contact.Remark == "" ? contact.NickName : contact.Remark;
  370. }
  371. else
  372. {
  373. w.NickName = userId;
  374. }
  375. }
  376. }
  377. // 发送人名字处理
  378. if (w.IsSender)
  379. w.NickName = "我";
  380. w.DisplayContent = w.StrContent;
  381. // 额外格式处理
  382. if (w.Type != 1)
  383. {
  384. if (w.Type == 10000)
  385. {
  386. w.Type = 1;
  387. w.NickName = "系统消息";
  388. w.DisplayContent = w.StrContent.Replace("<revokemsg>", "").Replace("</revokemsg>", "");
  389. }
  390. else if (w.Type == 49 && (w.SubType == 6 || w.SubType == 19 || w.SubType == 40))
  391. {
  392. WXSessionAttachInfo? attachInfos = GetWXMsgAtc(w);
  393. if (attachInfos == null)
  394. {
  395. w.DisplayContent = "附件不存在";
  396. }
  397. else
  398. {
  399. w.DisplayContent = Path.Combine(UserBakConfig!.UserResPath, attachInfos.attachPath);
  400. }
  401. }
  402. else
  403. {
  404. w.DisplayContent = "[界面未支持格式]Type=" + w.Type;
  405. }
  406. }
  407. tmp.Add(w);
  408. }
  409. }
  410. return tmp;
  411. }
  412. public List<WXSessionAttachInfo>? GetWXMsgAtc()
  413. {
  414. SQLiteConnection? con = getCon("MultiSearchChatMsg");
  415. if (con == null)
  416. return null;
  417. string query = "select * from SessionAttachInfo";
  418. List<WXSessionAttachInfo> list = con.Query<WXSessionAttachInfo>(query);
  419. if (list.Count != 0)
  420. {
  421. return list;
  422. }
  423. else
  424. return null;
  425. }
  426. public WXSessionAttachInfo? GetWXMsgAtc(WXMsg msg)
  427. {
  428. SQLiteConnection? con = getCon("MultiSearchChatMsg");
  429. if (con == null)
  430. return null;
  431. string query = "select * from SessionAttachInfo where msgId = ? order by attachsize desc";
  432. List<WXSessionAttachInfo> list = con.Query<WXSessionAttachInfo>(query, msg.MsgSvrID);
  433. if (list.Count != 0)
  434. {
  435. //部分附件可能有md5校验,这里移除校验,给的是正确路径
  436. WXSessionAttachInfo acc = list[0];
  437. int index = acc.attachPath.IndexOf(".dat");
  438. int index2 = acc.attachPath.IndexOf(".dat");
  439. if (acc.attachPath.Length - index > 10 && index != -1)
  440. {
  441. acc.attachPath = acc.attachPath.Substring(0, acc.attachPath.Length - 32);
  442. }
  443. if (acc.attachPath.Length - index2 > 10 && index2 != -1)
  444. {
  445. acc.attachPath = acc.attachPath.Substring(0, acc.attachPath.Length - 32);
  446. }
  447. return acc;
  448. }
  449. else
  450. return null;
  451. }
  452. public WXMediaMsg? GetVoiceMsg(WXMsg msg)
  453. {
  454. for (int i = 0; i <= 99; i++)
  455. {
  456. SQLiteConnection? con = getCon("MediaMSG" + i.ToString());
  457. if (con == null)
  458. continue;
  459. string query = "select * from Media where Reserved0=?";
  460. List<WXMediaMsg> wXMsgs = con.Query<WXMediaMsg>(query, msg.MsgSvrID);
  461. if (wXMsgs.Count != 0)
  462. return wXMsgs[0];
  463. }
  464. return null;
  465. }
  466. public string? GetAttachment(WXMsgType type, WXMsg msg)
  467. {
  468. if (UserBakConfig == null)
  469. return null;
  470. string? tmpPath = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Temp");
  471. if (!Directory.Exists(tmpPath))
  472. Directory.CreateDirectory(tmpPath);
  473. // 这部分是查找
  474. // 如果是图片和视频,从附件库中搜索
  475. string? path = null;
  476. if (type == WXMsgType.Image || type == WXMsgType.Video || type == WXMsgType.File)
  477. {
  478. WXSessionAttachInfo? atcInfo = GetWXMsgAtc(msg);
  479. if (atcInfo == null)
  480. return null;
  481. path = atcInfo.attachPath;
  482. }
  483. // 如果是从语音,从媒体库查找
  484. else if (type == WXMsgType.Audio)
  485. {
  486. WXMediaMsg? voiceMsg = GetVoiceMsg(msg);
  487. if (voiceMsg == null)
  488. return null;
  489. if (voiceMsg.Buf == null)
  490. return null;
  491. // 从DB取音频文件到临时目录
  492. string tmp_file_path = Path.Combine(tmpPath, voiceMsg.Key + ".arm");
  493. using (FileStream stream = new FileStream(tmp_file_path, FileMode.OpenOrCreate))
  494. {
  495. stream.Write(voiceMsg.Buf, 0, voiceMsg.Buf.Length);
  496. }
  497. path = tmp_file_path;
  498. }
  499. else if (type == WXMsgType.Emoji)
  500. {
  501. try
  502. {
  503. XmlDocument xmlDocument = new XmlDocument();
  504. xmlDocument.LoadXml(msg.StrContent);
  505. XmlNode? node = xmlDocument.SelectSingleNode("/msg/emoji");
  506. if (node != null)
  507. {
  508. if (node.Attributes != null)
  509. {
  510. XmlNode? item = node.Attributes.GetNamedItem("md5");
  511. string md5 = item != null ? item.InnerText : "";
  512. if (EmojiCache.ContainsKey(md5))
  513. {
  514. path = string.Format("Emoji\\{0}.gif", md5);
  515. }
  516. }
  517. }
  518. }
  519. catch
  520. {
  521. return null;
  522. }
  523. }
  524. if (path == null)
  525. return null;
  526. // 这部分是解密
  527. // 获取到原路径后,开始进行解密转移,只有图片和语音需要解密,解密后是直接归档目录
  528. if (type == WXMsgType.Image || type == WXMsgType.Audio)
  529. {
  530. path = DecryptAttachment(type, path, msg.StrTalker);
  531. }
  532. else if (type == WXMsgType.Video || type == WXMsgType.File)
  533. {
  534. string to_dir;
  535. if (type == WXMsgType.Video)
  536. to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Video");
  537. else
  538. to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "File");
  539. if (!Directory.Exists(to_dir))
  540. Directory.CreateDirectory(to_dir);
  541. FileInfo fileInfo = new FileInfo(path);
  542. // 目标视频路径
  543. string to_file_path = Path.Combine(to_dir, fileInfo.Name);
  544. // 视频的路径是相对路径,需要加上资源目录
  545. path = Path.Combine(UserBakConfig.UserResPath, path);
  546. // 原文件存在,目标不存在
  547. if (!File.Exists(to_file_path) && File.Exists(path))
  548. {
  549. // 复制
  550. File.Copy(path, to_file_path);
  551. path = to_file_path;
  552. }
  553. else if (File.Exists(to_file_path))
  554. {
  555. path = to_file_path;
  556. }
  557. else
  558. return null;
  559. }
  560. if (path == null)
  561. return null;
  562. // 改相对路径
  563. path = path.Replace(UserBakConfig.UserWorkspacePath + "\\", "");
  564. return path;
  565. }
  566. public string? DecryptAttachment(WXMsgType type, string path,string username)
  567. {
  568. if (UserBakConfig == null)
  569. return null;
  570. string? file_path = null;
  571. switch (type)
  572. {
  573. case WXMsgType.Image:
  574. string img_dir = Path.Combine(UserBakConfig.UserWorkspacePath, username, "Image");
  575. if (!Directory.Exists(img_dir))
  576. Directory.CreateDirectory(img_dir);
  577. // 图片的路径是相对路径,需要加上资源目录
  578. path = Path.Combine(UserBakConfig.UserResPath, path);
  579. if (!File.Exists(path))
  580. return null;
  581. byte[] decFileByte = DecryptionHelper.DecImage(path);
  582. if (decFileByte.Length < 2)
  583. new Exception("解密失败,可能是未支持的格式");
  584. string decFiletype = DecryptionHelper.CheckFileType(decFileByte);
  585. file_path = DecryptionHelper.SaveDecImage(decFileByte, path, img_dir, decFiletype);
  586. break;
  587. case WXMsgType.Audio:
  588. string audio_dir = Path.Combine(UserBakConfig.UserWorkspacePath, username, "Audio");
  589. if (!Directory.Exists(audio_dir))
  590. Directory.CreateDirectory(audio_dir);
  591. FileInfo fileInfo = new FileInfo(path);
  592. string audio_file_dir = Path.Combine(audio_dir, fileInfo.Name + ".mp3");
  593. ToolsHelper.DecodeVoice(path, path + ".pcm", audio_file_dir);
  594. file_path = audio_file_dir;
  595. break;
  596. }
  597. return file_path;
  598. }
  599. public List<WXMsgGroup> GetWXMsgGroup()
  600. {
  601. List<WXMsgGroup> g = new List<WXMsgGroup>();
  602. for (int i = 0; i <= 99; i++)
  603. {
  604. SQLiteConnection? con = getCon("MSG" + i.ToString());
  605. if (con == null)
  606. return g;
  607. string query = "select StrTalker,Count(localId) as MsgCount from MSG GROUP BY StrTalker";
  608. List<WXMsgGroup> wXMsgs = con.Query<WXMsgGroup>(query);
  609. foreach (WXMsgGroup w in wXMsgs)
  610. {
  611. WXMsgGroup? tmp = g.Find(x => x.UserName == w.UserName);
  612. if (tmp == null)
  613. g.Add(w);
  614. else
  615. tmp.MsgCount += g.Count;
  616. }
  617. }
  618. return g;
  619. }
  620. }
  621. public enum WXMsgType
  622. {
  623. Image = 0,
  624. Video = 1,
  625. Audio = 2,
  626. File = 3,
  627. Emoji = 4,
  628. }
  629. }