Explorar el Código

fix 添加部分异常处理

Zhangtaotao hace 6 años
padre
commit
f2d8c48f75
Se han modificado 2 ficheros con 25 adiciones y 2 borrados
  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;