Kaynağa Gözat

fix 添加部分异常处理

Zhangtaotao 6 yıl önce
ebeveyn
işleme
f2d8c48f75
2 değiştirilmiş dosya ile 25 ekleme ve 2 silme
  1. 3 0
      .gitignore
  2. 22 2
      WeChatCore/WeiChat.cs

+ 3 - 0
.gitignore

@@ -17,3 +17,6 @@ WeChatCore/obj/Debug/WeChatCore.dll
 WeChatCore/obj/Debug/WeChatCore.g.resources
 WeChatCore/obj/Debug/WeChatCore.pdb
 WeChatCore/obj/Debug/WeChatCore.csprojResolveAssemblyReference.cache
+WeChatCore/bin/Debug/Data/data.dat
+WeChatCore/obj/Debug/WeChatCore.csproj.CopyComplete
+WeChatCore/obj/Debug/WeChatCore.csproj.CoreCompileInputs.cache

+ 22 - 2
WeChatCore/WeiChat.cs

@@ -17,6 +17,9 @@ using WeChatCore.Enum;
 
 namespace WeChatCore
 {
+    /// <summary>
+    /// weichat
+    /// </summary>
     public static class WeiChat
     {
         #region 初始化微信机器人
@@ -35,10 +38,22 @@ namespace WeChatCore
                 CommonDefine.GetMsgSyncKey = GetSyncKey();
                 while (true)
                 {
-                    LogWriter.Write(string.Format("获取心跳信息..."), LogPathDefine.WeChatLogPath);
-                    KeepHeart(CommonDefine.GetMsgSyncKey);
+                    try
+                    {
+                        LogWriter.Write(string.Format("获取心跳信息..."), LogPathDefine.WeChatLogPath);
+                        KeepHeart(CommonDefine.GetMsgSyncKey);
+                    }
+                    catch (Exception ex)
+                    {
+                        LogWriter.Write(string.Format(ex.Message), LogPathDefine.ExceptionLogPath);
+                    }
                 }
             }
+            else
+            {
+                LogWriter.Write(string.Format("下载验证码失败,请重试..."), LogPathDefine.WeChatLogPath);
+                throw new Exception("下载验证码失败,请重试...");
+            }
         }
 
         #endregion
@@ -560,6 +575,11 @@ namespace WeChatCore
                         me.FilePath = Environment.CurrentDirectory + "\\" + DirectoryDefine.MapImageMsgPath + "\\" + FileId + ".jpg";
                         me.MsgTime = DateTime.Now;
                     }
+                    else if (ali.MsgType == 10000)
+                    {
+                        me.MsgType = MsgTypeEnum.SystemMsg;
+                        me.MsgTime = DateTime.Now;
+                    }
                     else
                     {
                         me.MsgType = MsgTypeEnum.Text;